Forum Discussion
TOPN Across Multiple Columns
- 6 years ago
Hi DLB13 ,
1. Select the 'Respondent' column and right click to unpivot other columns in power queries, close and apply it.
2. Create a measure like this:
TOP3 = VAR tab = ADDCOLUMNS ( DISTINCT ( 'Table'[Attribute] ), "Count", VAR attr = 'Table'[Attribute] RETURN COUNTROWS ( FILTER ( ALL ( 'Table' ), 'Table'[Attribute] = attr && 'Table'[Value] = attr ) ) ) VAR newtab = ADDCOLUMNS ( tab, "Rank", RANKX ( tab, [Count],, DESC, DENSE ) ) RETURN CONCATENATEX ( FILTER ( newtab, [Rank] = 1 ), [Attribute], "," ) & " " & CONCATENATEX ( FILTER ( newtab, [Rank] = 2 ), [Attribute], "," ) & " " & CONCATENATEX ( FILTER ( newtab, [Rank] = 3 ), [Attribute], "," ) 3. Put the measure in a card visual and you will get the top3 sports:
Here is the sample file that hopes to help you, please try it: PBIX
In this sample file I also created a rank table for reference that you can refer.
Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- 6 years ago
Hi DLB13 ,
1. Select the 'Respondent' column and right click to unpivot other columns in power queries, close and apply it.
2. Create a measure like this:
TOP3 =
VAR tab =
ADDCOLUMNS (
DISTINCT ( 'Table'[Attribute] ),
"Count",
VAR attr = 'Table'[Attribute]
RETURN
COUNTROWS (
FILTER ( ALL ( 'Table' ), 'Table'[Attribute] = attr && 'Table'[Value] = attr )
)
)
VAR newtab =
ADDCOLUMNS ( tab, "Rank", RANKX ( tab, [Count],, DESC, DENSE ) )
RETURN
CONCATENATEX ( FILTER ( newtab, [Rank] = 1 ), [Attribute], "," ) & " "
& CONCATENATEX ( FILTER ( newtab, [Rank] = 2 ), [Attribute], "," ) & " "
& CONCATENATEX ( FILTER ( newtab, [Rank] = 3 ), [Attribute], "," )
3. Put the measure in a card visual and you will get the top3 sports:
Here is the sample file that hopes to help you, please try it: PBIX
In this sample file I also created a rank table for reference that you can refer.
Best Regards,
Yingjie Li
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.