• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Display sum of value for a TOPN selection

Lolo

Member
Hello,

I have a basic question:

Suppose I have a table with 3 columns :

City / Month / Value
An I have 100 cities for example.

I want to create a pivot table by using a DAX measure,
for only the top 10 of cities, and have the sum of values for each of the 10.
Actually I want simply do like the existing TOPN function of Excel pivot tables...

I have tried TOPN and RANKX DAX functions, but each time I still have ALL the 100 cities in my pivot table.

How could I do that ?

Thank you for your help.
 
Hum... Actually I now manage to do it :

Sum Values (TOP 10):=
VAR SelectedTop = 10
RETURN
SWITCH(TRUE();
SelectedTop = 0; [SumValues];
RANKX (
ALLSELECTED(FactImbalance[CITY]);
[SumValues]
)
<= SelectedTop;
[SumValues]
)

But my second problem is now to display these 10 TOP cities (with a bubble that represents the value) on a map in Powerview.

Problem is that for cities data, I use a dimension table (usual way to do) with city/city name/Longitude/Latitude.
And I'm obliged to use the city code of the dimension table to display data on the map.
So ALL 100 cities are displayed, not only the TOP 10 :(
If I try to use the city code of my fact table, map is not correctly displayed :(
 
Please find attached a sample file.

- DATA sheet contains sample data
- PIVOT sheet contains a pivot table with the TOP 10 (and it is correct)
- And Power view sheet contains a map and a table with normally the same data, but result is incorrect, it is showing more than my TOP 10 points :(
 

Attachments

  • Test.xlsx
    367.6 KB · Views: 0
OK found myself the answer :)

There is a trick on the map that I need to do:
* Add an additional measure with RANKX only.
And this measure is added as a filter of the map, and I filter the measure with values <=10 (to get only the TOP10).

For the table in powerview, there was an issue, since I have just recreated the table, and now it only display the top10...


See file attached.
 

Attachments

  • Test_TOPN and MAP.xlsx
    364.2 KB · Views: 3
Back
Top