Aggregation Functions () | Power BI || Belayet Hossain
Belayet Hossain ??
Power BI Developer @ZnZ | Data Analyst | SQL, Python, ETL, DBMS, DAX | Find insight & Making Decision|| Ex-Head of Quality Dept & 09 Y With smartphone Manufacturing & Service | Ex- RFL, VIVO, Symphony || EEE
An aggregate function in Power BI is a type of function that performs a calculation on a set of values and returns a single value.
These functions are commonly used to summarize data, allowing you to compute totals, averages, counts, and other statistics.
Aggregate functions are essential in data analysis and reporting because they help simplify large datasets into meaningful insights.
??1. SUM
Scenario: Total sales for all products.
DAX = ??????('?????????????? ??????????'[??????????])
??2. SUMX
Scenario: Total revenue from sales for all products.
DAX: ?????????????????????????????? = ????????(??????????, ??????????[??????????????????????] * ??????????[??????????])
100*10 + 200*20 + 150*15 = 1000+4000+2250=7250
??3. COUNT
Scenario: Counting the number of sales transactions with recorded amounts.
DAX: CountSales = COUNT(Sales[SalesAmount])
??4. COUNTA
Scenario: Use to count products with a value in the sales column, ignoring blanks.
DAX: CountNonBlank = COUNTA(Sales[SalesAmount])
??5. COUNTAX
Scenario: Counting the number of products with sales amounts greater than 100.
DAX: CountSalesAbove100 = COUNTAX(Sales, Sales[SalesAmount] > 100)
??6. COUNTX
Scenario: Counting the number of products with more than 15 units.
DAX: CountUnitsAbove15 = COUNTX(Sales, Sales[Units] > 15)
??7. COUNTROWS
Scenario: Counting the total number of sales records.
DAX: RowCount = COUNTROWS(Sales)
??8. AVERAGE
Scenario: Finding the average sales amount per product.
DAX: AverageSales = AVERAGE(Sales[SalesAmount])
??9. AVERAGEA
Scenario: You want to calculate the average of the Value column, considering the text and logical values using the AVERAGEA function.
DAX: AverageA_Value = AVERAGEA(TableA[Value])
>> 10, 5, and 20 are numbers and are included in the average calculation.
>> TRUE is treated as 1.
>> FALSE and the text value "Text" are treated as 0.
So the calculation would be: Average= 10+1+5+0+0+20=36 /6 = 6
??10. AVERAGEX
Scenario: We want to calculate the average revenue per product. Revenue is calculated as Units Sold * Unit Price for each row.
DAX: AverageRevenuePerProduct = AVERAGEX ( SalesTable, SalesTable[Units Sold] * SalesTable[Unit Price] )
(10*15 + 20*12 + 30*18 + 40*10 = 150 + 240 + 540 + 400 = 1330 / 4 = 332.5
??11. DISTINCTCOUNT
Scenario: Finding the number of distinct sales amounts.
DAX: UniqueProducts = DISTINCTCOUNT(Sales[SalesAmount])
领英推荐
??12. DISTINCTCOUNTNOBLANK
Scenario: Finding the number of unique non-blank sales amounts.
DAX: UniqueNonBlankProducts = DISTINCTCOUNTNOBLANK(Sales[SalesAmount])
??13. MAX
Scenario: Finding the highest sales amount.
DAX: MaxSales = MAX(Sales[SalesAmount])
??14. MAXA
Numeric values: It returns the highest number.
Text values: It returns 0 if text is present in the column.
Logical values: It treats TRUE as 1 and FALSE as 0.
Scenario: To find the maximum value in the SalesAmount column, considering both numeric and non-numeric data:
DAX: MAXA(SalesData[SalesAmount])
??15. MAXX
Scenario: You want to find the maximum revenue (UnitsSold * UnitPrice) from the table.
DAX: MAXX('Sales', 'Sales'[UnitsSold] * 'Sales'[UnitPrice])
Table: Sales
10*200 = 200, 5*15= 75 , 8*25 = 200
The maximum value is 200, so MAXX returns 200.
??16. MIN
Scenario: Finding the lowest sales amount.
DAX: MinSales = MIN(Sales[SalesAmount])
??17. MINA
Text values are considered smaller than numbers.
Boolean values are treated as TRUE = 1 and FALSE = 0.
Scenario:
DAX: SmallestValue = MINA(TableA[Value])
Table: TableA
FALSE is treated as 0, which is the smallest.
Text is considered smaller than numbers, so it would be the smallest if present, depending on the dataset.
For this specific data set, "Text" would be the smallest value.
??18. MINX
Scenario: We want to compute the smallest total sales value across the products.
DAX: MINX(SalesTable, SalesTable[Quantity] * SalesTable[Price])
The smallest total sales value is 150, so the result of the MINX function will be 150.
??19. PRODUCT
Scenario: Multiply all sales together.
DAX: PRODUCT('Product Sales'[Sales])
??Key Difference:
#powerbi #aggregate #fucntion #dax #measure
??????? ????? ??????? ?? Accounts Executive || MIS Executive || MYSql ||Microsoft Power BI
2 个月Wow, this post is aggregating all the knowledge I need to sum up my Power BI skills! ???? I always knew COUNTing on Power BI would MAXimize my data game, but this is next level! Thanks for the detailed breakdown—now I can AVERAGEly impress my colleagues with my newfound DAXpertise! ???? #DataNerd #PowerBIWiz