Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
RanjitGupta
New Member

Rank based on columns conditions and rows [in measure]

Hi,

 

Thankyou for the help in advance. 

 

I am trying to create a measure which will rank my set of names based on the rank in columns. I have attached an image as example. In the final output the rank should be prioritized by the rows starting A, B,C,D,E and so on. 

 

 

 

 

 unnamed.jpg

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @RanjitGupta ,

 

You can try this method.

 

New table:

Table 2 = Var _Table = UNION(



    SUMMARIZE('Table','Table'[Type],'Table'[A]),



    SUMMARIZE('Table','Table'[Type],'Table'[B]),



    SUMMARIZE('Table','Table'[Type],'Table'[C]),



    SUMMARIZE('Table','Table'[Type],'Table'[D]),



    SUMMARIZE('Table','Table'[Type],'Table'[E]),



    SUMMARIZE('Table','Table'[Type],'Table'[F]))



return



DISTINCT(FILTER(_Table,[A]="1"))

Measure:

Measure = IF(SELECTEDVALUE('Table'[Type]) in VALUES('Table 2'[Type]),1,0)

vyinliwmsft_0-1664348798295.png

 

 

Is this the result you would expect?

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yinliw-msft
Community Support
Community Support

Hi @RanjitGupta ,

 

You can try this method.

 

New table:

Table 2 = Var _Table = UNION(



    SUMMARIZE('Table','Table'[Type],'Table'[A]),



    SUMMARIZE('Table','Table'[Type],'Table'[B]),



    SUMMARIZE('Table','Table'[Type],'Table'[C]),



    SUMMARIZE('Table','Table'[Type],'Table'[D]),



    SUMMARIZE('Table','Table'[Type],'Table'[E]),



    SUMMARIZE('Table','Table'[Type],'Table'[F]))



return



DISTINCT(FILTER(_Table,[A]="1"))

Measure:

Measure = IF(SELECTEDVALUE('Table'[Type]) in VALUES('Table 2'[Type]),1,0)

vyinliwmsft_0-1664348798295.png

 

 

Is this the result you would expect?

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I suggest having a table structure transformed like below in Power Query Editor.

 

You can also see the below applied-steps by opening the attached pbix file -> go to Power Query Editor.

 

Power Query advanced editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV0lEyBGIzJNoIiM2VYnWilZwSi7NTS+BCCNoEzAYpcU4EyRtDtRtD1RiDMUjeJT8drh5CG0KxCVjeLbM4A8gxhWpCpk0hFuSXQ91lgkabgeV980uLU6HOMkWjDZViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, A = _t, B = _t, C = _t, D = _t, E = _t, F = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Category"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Category"}, {{"IndexAdd", each Table.AddIndexColumn( _, "Index",1,1)}}),
    #"Expanded IndexAdd" = Table.ExpandTableColumn(#"Grouped Rows", "IndexAdd", {"Attribute", "Value", "Index"}, {"Attribute", "Value", "Index"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded IndexAdd",{{"Category", type text}, {"Attribute", type text}, {"Value", Int64.Type}, {"Index", Int64.Type}})
in
    #"Changed Type"

 

 

Jihwan_Kim_1-1664344437335.png

 

 

And then, load it and try to create a measure and a table visualization like below.

 

Jihwan_Kim_0-1664344401779.png

 

DAX measure:

Final output measure: =
VAR _currentindex =
    MAX ( Data[Index] )
VAR _newtable =
    FILTER (
        ADDCOLUMNS (
            ALL ( Data[Attribute], Data[Index] ),
            "@rankonecategory", CALCULATE ( MAXX ( FILTER ( Data, Data[Value] = 1 ), Data[Category] ) )
        ),
        Data[Index] < _currentindex
    )
VAR _prevrankonecategorylist =
    SUMMARIZE ( _newtable, [@rankonecategory] )
VAR _result =
    MAXX ( FILTER ( Data, Data[Value] = 1 ), Data[Category] )
RETURN
    IF (
        HASONEVALUE ( Data[Attribute] ),
        IF ( _result IN _prevrankonecategorylist, BLANK (), _result )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.