Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
What if we need to display Top N/Bottom N products and regions both.
It should show only top 5 or bottom 5 products and regions. Only 5 row table.
Following measure works for only products.
Like this?
Solved! Go to Solution.
Hi @Anonymous,
Thank you for reaching out to the Microsoft fabric community forum. I reproduced the scenario again, and it worked on my end. I used my sample data and successfully implemented it.
See there is No relationship between Products and Regions:
Outcome:
I am also including .pbix file for your better understanding, please have a look into it:
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
Hi @Anonymous,
Thank you for reaching out to the Microsoft fabric community forum. Also thanks to @bhanu_gautam, for his inputs on this thread. I reproduced the scenario, and it worked on my end. I used my sample data and successfully implemented it.
Outcome:
I am also including .pbix file for your better understanding, please have a look into it:
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
Awesome solution,
But state name and Product name are in different table. Which has no relationship between them.
What can we do about that?
What needs to be changed?
Please show us required code according to this.
Hi @Anonymous,
Thank you for reaching out to the Microsoft fabric community forum. I reproduced the scenario again, and it worked on my end. I used my sample data and successfully implemented it.
See there is No relationship between Products and Regions:
Outcome:
I am also including .pbix file for your better understanding, please have a look into it:
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
@Anonymous To display the top 5 or bottom 5 products and regions, you need to modify your measure to account for both products and regions.
dynamic time period with top rank =
VAR N = SELECTEDVALUE('Top N Value'[Top N Value])
VAR RankType = SELECTEDVALUE('TopBottom Selector'[RankType])
VAR IsTop = RankType = "Top"
VAR IsBottom = RankType = "Bottom"
VAR BaseMeasure = [Dyanamic Time Period Measure]
// Create a table of products and regions with non-blank measure values
VAR CombinedTable =
FILTER(
CROSSJOIN(ALLSELECTED(Products[ProductName]), ALLSELECTED(Regions[RegionName])),
NOT ISBLANK(CALCULATE([Dyanamic Time Period Measure]))
)
// Rank combined products and regions based on the selected measure
VAR CombinedRankTop =
RANKX(
CombinedTable,
CALCULATE([Dyanamic Time Period Measure]),
,
DESC
)
VAR CombinedRankBottom =
RANKX(
CombinedTable,
CALCULATE([Dyanamic Time Period Measure]),
,
ASC
)
RETURN
SWITCH(
TRUE(),
IsTop && CombinedRankTop <= N, BaseMeasure,
IsBottom && CombinedRankBottom <= N, BaseMeasure,
BLANK()
)
You may need to ensure that your Selected Measure top N rank measure is correctly integrated with this new logic.
Selected Measure top N rank =
SWITCH(
SELECTEDVALUE('Measure Selector'[Measure Name]),
"Sales", [dynamic time period with top rank],
"Quantity", [dynamic time period with top rank],
"GP", [dynamic time period with top rank]
)
Proud to be a Super User! |
|
This is complete different measure
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 36 | |
| 33 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 73 | |
| 72 | |
| 38 | |
| 35 | |
| 26 |