TOPN Dax | How to use topn dax in power bi | Power BI DAX Tutorial
Vložit
- čas přidán 24. 07. 2022
- 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:
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 par...
2.How to Calculate Running Totals: • How to calculate runni...
3.Duplicate Vs Reference : • power bi difference be...
4.Merge Vs Append: • power bi difference be...
5.Calculate Function in DAX Power BI: • What is Calculate Func...
6.Filter Function in Power BI: • Filter Function in Pow...
7.Row Vs Filter Context: • Row Context Vs Filter ...
8.ALL DAX Function: • How to use ALL Dax Fun...
9.ALL Vs ALLSELECTED : • allselected dax|all vs...
10.ALL Vs ALLSELECTED VS ALLEXCEPT : • All Vs AllSelected Vs ...
11.ALL Vs REMOVEFILTERS : • ALL Vs REMOVEFILTERS D...
Learn Power BI through our vlog and Free Videos:
powerbizone.com/category/arti...
You can download the pbix file for your self practice sessions from :
drive.google.com/file/d/1X-70...
Do not forget to Like ,Subscribe and comment which keeps me motivated !
You can download the pbix file for your self practice sessions from :
drive.google.com/file/d/1X-70Wj80aE4uoJU3kTJVoILlLCZdvp9s/view?usp=sharing
Do not forget to Like ,Subscribe and comment which keeps me motivated !
Thanks a lot! This is very useful to know. I always wondered how to use topN.
Glad it was helpful! :)