Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I would like to rank the top three values from each row and place it in the 1st, 2nd and 3rd row. In the figure below it shows for row 1 (for example), D has the highest value of 90 and it will show up in the 1st column. 20 is the second largest number will show up in 2nd column and so on for the 3rd column. The excel sheet is using formula of index match and large. Is there a way to do this in Power BI.
Thanks in advance
Solved! Go to Solution.
Here is one way to do this.
1. Add an index and unpivot your data in the query editor. I mocked up some data to demonstrate. To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYmMgNlGK1YkGkhAeSNQQLGIIloOJxsYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t, D = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", Int64.Type}, {"C", Int64.Type}, {"D", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Row", 1, 1, Int64.Type),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Row"}, "Attribute", "Value")
in
#"Unpivoted Other Columns"
I called the table "AD"
2. Make a second DAX table to hold your Rank values with an expression like this
Letter At Rank =
VAR vThisRank =
SELECTEDVALUE ( RankTable[Value] )
VAR vSummary =
ADDCOLUMNS (
VALUES ( AD[Attribute] ),
"cRank",
RANKX (
ALLSELECTED ( AD[Attribute] ),
CALCULATE (
SUM ( AD[Value] )
)
)
)
RETURN
MINX (
FILTER (
vSummary,
[cRank] = vThisRank
),
AD[Attribute]
)
4. Make a matrix visual with the RankValues on columns, the AD[Attribute] column on rows and the measure on values to get this result.
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi,
This will depend upon how the raw data is structured. Share the link from where i can download your PBI file.
Here is one way to do this.
1. Add an index and unpivot your data in the query editor. I mocked up some data to demonstrate. To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYmMgNlGK1YkGkhAeSNQQLGIIloOJxsYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t, D = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", Int64.Type}, {"C", Int64.Type}, {"D", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Row", 1, 1, Int64.Type),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Row"}, "Attribute", "Value")
in
#"Unpivoted Other Columns"
I called the table "AD"
2. Make a second DAX table to hold your Rank values with an expression like this
Letter At Rank =
VAR vThisRank =
SELECTEDVALUE ( RankTable[Value] )
VAR vSummary =
ADDCOLUMNS (
VALUES ( AD[Attribute] ),
"cRank",
RANKX (
ALLSELECTED ( AD[Attribute] ),
CALCULATE (
SUM ( AD[Value] )
)
)
)
RETURN
MINX (
FILTER (
vSummary,
[cRank] = vThisRank
),
AD[Attribute]
)
4. Make a matrix visual with the RankValues on columns, the AD[Attribute] column on rows and the measure on values to get this result.
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi Pat,
You solution looks good. I incorporated the solution on my pbi file. It shows some gaps inbetween. I have provided my snapshot of the issue. Would you know what the issue and solution would be?
Thanks in advance.
I will accept this solution because it did address my original question. However, it did not solve the next ask. I will see if I can find that solution.
Thank you for your help.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
113 | |
81 | |
45 | |
42 | |
27 |
User | Count |
---|---|
182 | |
83 | |
70 | |
48 | |
45 |