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
Hi,
I have the below tables in my data model - With the current RANKX expression I am able to Rank product sales across all cities but my desired output is to calculate sales of my products across different countries which is my dimension table and Rank sales based on product and across countries. Since I cannot use ALL(ProductID,Country) I am not sure how to get around this. Please help!
Thanks
1) Fact Sales
| ProductID | City | Sales |
| 1 | London | 100 |
| 2 | Paris | 300 |
| 1 | Paris | 300 |
| 3 | London | 250 |
| 2 | Milan | 350 |
| 1 | Milan | 150 |
2) Dim Country
| City | Country |
| London | UK |
| Paris | France |
| Milan | Italy |
Existing Measure - Calculate(RANKX(All('Fact Sales'[ProductID]), SUM(Sales),,DESC,),Removefilter('Dim Country'[Country]))
| ProductID | Country | Sales | Rank |
| 1 | UK | 100 | 2 |
| 1 | France | 300 | 2 |
| 1 | Italy | 150 | 2 |
| 2 | France | 300 | 1 |
| 2 | Italy | 350 | 1 |
| 3 | UK | 250 | 3 |
Expected Output
| ProductID | Country | Sales | Rank |
| 1 | UK | 100 | 5 |
| 1 | France | 300 | 2 |
| 1 | Italy | 150 | 4 |
| 2 | France | 300 | 2 |
| 2 | Italy | 350 | 1 |
| 3 | UK | 250 | 3 |
Solved! Go to Solution.
@2366 , Try Rank like
RANKX(Summarize(All('Fact Sales'),'Fact Sales'[ProductID],'Dim Country'[Country] ), SUM(Sales),,DESC,)
Power BI Rank Across dimension tables: https://youtu.be/X59qp5gfQoA
Hi,
In this case, auto-exist will not apply and so you need to be careful to avoid ending up with a visual which contains additional entries due to the cross-join between the two tables. So I would try something like:
Measure =
VAR T1 =
ADDCOLUMNS(
ADDCOLUMNS(
'Fact Sales',
"Country", RELATED( 'Dim Country'[Country] )
),
"MyRank",
RANKX(
ALL( 'Fact Sales' ),
'Fact Sales'[Sales],
,
,
DENSE
)
)
RETURN
MINX(
T1,
[MyRank]
)
Regards
@2366 , Try Rank like
RANKX(Summarize(All('Fact Sales'),'Fact Sales'[ProductID],'Dim Country'[Country] ), SUM(Sales),,DESC,)
Power BI Rank Across dimension tables: https://youtu.be/X59qp5gfQoA
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 |
|---|---|
| 9 | |
| 8 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 23 | |
| 14 | |
| 10 | |
| 6 | |
| 5 |