Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Dear Experts:
I have got a table visual as follows:
It shows the Top 5 Countries by Category Sales. along with a Ranking Column. It works just fine.
The two measures Top5Countries and Ranking are as follows (please see below). They work just fine everything is ok.
Now here comes my question: How can I retrieve The Total Sales as depicted in the Table Visual (142,171,598 €) and have that value displayed in a card visual.
Help is very much appreciated. Thank you very much in advance. Regards, Andreas
Solved! Go to Solution.
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
In this case, one of ways is using WINDOW and RANK DAX functions in measures.
Please check the below picture and the attached pbix file.
WINDOW function (DAX) - DAX | Microsoft Learn
RANK function (DAX) - DAX | Microsoft Learn
Total sales: =
SUM(sales[sales])
Top 5 countries within category: =
VAR _topn =
WINDOW (
1,
ABS,
5,
ABS,
SUMMARIZE (
ALL ( sales ),
category[category],
country[country]
),
ORDERBY ( [Total sales:], DESC ),
,
PARTITIONBY ( category[category] )
)
RETURN
CALCULATE (
[Total sales:],
KEEPFILTERS ( _topn )
)
Ranking: =
IF (
[Top 5 countries within category:],
RANK (
SKIP,
SUMMARIZE (
ALL ( sales ),
category[category],
country[country]
),
ORDERBY ( [Total sales:], DESC ),
,
PARTITIONBY ( category[category] )
)
)
Wow Kim,
I am deeply impressed by your expertise. That's the way I wanted it. Thank you very much for your great help. I really appreciate it.
Best Regards, Andreas
Hi @AndreasHermle,
May i know has your issue been resolved? If the response provided by the community member @Jihwan_Kim, addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.
If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.
Thank you for your understanding!
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
In this case, one of ways is using WINDOW and RANK DAX functions in measures.
Please check the below picture and the attached pbix file.
WINDOW function (DAX) - DAX | Microsoft Learn
RANK function (DAX) - DAX | Microsoft Learn
Total sales: =
SUM(sales[sales])
Top 5 countries within category: =
VAR _topn =
WINDOW (
1,
ABS,
5,
ABS,
SUMMARIZE (
ALL ( sales ),
category[category],
country[country]
),
ORDERBY ( [Total sales:], DESC ),
,
PARTITIONBY ( category[category] )
)
RETURN
CALCULATE (
[Total sales:],
KEEPFILTERS ( _topn )
)
Ranking: =
IF (
[Top 5 countries within category:],
RANK (
SKIP,
SUMMARIZE (
ALL ( sales ),
category[category],
country[country]
),
ORDERBY ( [Total sales:], DESC ),
,
PARTITIONBY ( category[category] )
)
)
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
24 | |
13 | |
12 | |
10 | |
6 |