TOPN Dax | How to use topn dax in power bi | Power BI DAX Tutorial

Опубликовано: 15 Октябрь 2024
на канале: PowerBI Zone
2,111
56

In todays Dax tutorial we learn the usage of TOPN Dax Function in Power BI.
Usage of TOPN : Returns the top N rows of the specified table.
Syntax of TOPN: TOPN(N_Value, Table, OrderBy_Expression, [Order[, OrderBy_Expression, [Order]]…])
Parameter details of TOPN Dax Function in Power BI are given below:
N_Value The number of rows to return.
Table Any DAX expression that returns a table of data from where to extract the top 'n' rows.
OrderBy_Expression Any DAX expression where the result value is used to sort the table
Order (Optional) A value that specifies how to sort OrderBy_Expression values:
0 (zero) or FALSE. Sorts in descending order of values of Order.
1 or TRUE. Hence It can be ASC or DESC
Example 1: It can be used to create a table as shown below without specifying the order

Top 5 Rows (DB) =
TOPN(
5,financials)
Example 2: It can be used to create a table as shown below with specifying the order

Top 5 Rows (Sales) =
TOPN(
5,
financials,
financials[ Sales],ASC
)
Example 3: It can be used to refer to an Virtual table created by Power BI

Top 3 Countries (Sales) =
TOPN(
3,
SUMMARIZE(
financials,
financials[Country],
"Sales",Sum(financials[ Sales])
),
[Sales],
DESC
)
Example 4: The TOPN Dax Function can be used to create a measure as shown below

TOP 2 Countries(Avg Sales) =
AVERAGEX(
TOPN(
2,
SUMMARIZE(
financials,
financials[Country],
"Sales1",Sum(financials[ Sales])
),
[Sales1]),
[Sales1]

)

Hence TOPN can both be used to create tables and measures.
For more detailed usage of TOPN Dax function in Power BI refer below:
https://powerbizone.com/dax-topn-exam...

#powerbi #powerbitraining #powerbidax #powerbi_training #daxfunctions #powerbizone

Chapters:
0:28 :Introduction to TOPN DAX in Power BI
1:07 Syntax of TOPN Dax
2:12 Example /Usage 1 of TOPN Dax
3:44 Example /Usage 2 of TOPN Dax
4:43 Example /Usage 3 of TOPN Dax
6:04 Example /Usage 4 of TOPN Dax (using Measure)


Check out other Power BI Tutorials Videos :
1.SamePeriodLastYear with Example:    • difference between parallelperiod and...  
2.How to Calculate Running Totals:    • How to calculate running total in pow...  
3.Duplicate Vs Reference :    • power bi difference between duplicate...  
4.Merge Vs Append:    • power bi difference between merge and...  
5.Calculate Function in DAX Power BI:    • What is Calculate Function in Power B...  
6.Filter Function in Power BI:    • Filter Function in Power BI DAX  
7.Row Vs Filter Context:    • Row Context Vs Filter Context in Powe...  
8.ALL DAX Function:    • How to use ALL Dax Function in Power ...  
9.ALL Vs ALLSELECTED :    • allselected dax|all vs allselected da...  
10.ALL Vs ALLSELECTED VS ALLEXCEPT :    • All Vs AllSelected Vs AllExcept | Pow...  
11.ALL Vs REMOVEFILTERS :    • ALL Vs REMOVEFILTERS Difference in Po...  

Learn Power BI through our vlog and Free Videos:
https://powerbizone.com/category/arti...

You can download the pbix file for your self practice sessions from :
https://drive.google.com/file/d/1X-70...
Do not forget to Like ,Subscribe and comment which keeps me motivated !