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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
riishabhzz
Employee
Employee

Rank Dax help

hi everyone 

 

Need your help to get Rank Dax .

Below table is the requirement.

rank dax should be based on name and solutions for FY basis.

for ex:-  A name with abc solution in FY23 should be rank 1

also Name is from Name table ,solutions is from solution table and FY is from time table .

any help will be appreciated 🙂 

 

namesolutionsFYrank
Aabcfy231
Aabcfy222
Aabcfy213
Adeffy211
Babcfy231
Babcfy222
Babcfy213
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @riishabhzz ,

 

I noticed that you have three tables and your fields in your table visual are from different tables.

vstephenmsft_2-1674117999381.png

And because of the model relationships, when you put the right rank meausre into it, fields will be changed.

vstephenmsft_0-1674117951095.png

vstephenmsft_4-1674118070442.png

It's a little hard to explain, but that's the way it is.

If you want to keep the expected output when you post, try to make your Name and FY from the Solutions table.

And you'll get the right output.

 

Rank = RANKX(FILTER(ALLSELECTED(Solution),[Solutions]=MAX('Solution'[Solutions])&&[Name]=MAX('Name'[Name])),CALCULATE(MAX('Time'[FY])),,ASC,Dense)
Rank2 = RANKX(FILTER(ALLSELECTED(Solution),[Name]=MAX('Solution'[Name])&&[Solutions]=MAX('Solution'[Solutions])),CALCULATE(MAX('Solution'[FY])),,ASC,Dense)

 

Both measures can return the right values.

vstephenmsft_6-1674118431558.png

 

 

Best Regards,

Stephen Tao

 

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

7 REPLIES 7
v-stephen-msft
Community Support
Community Support

Hi @riishabhzz ,

 

I noticed that you have three tables and your fields in your table visual are from different tables.

vstephenmsft_2-1674117999381.png

And because of the model relationships, when you put the right rank meausre into it, fields will be changed.

vstephenmsft_0-1674117951095.png

vstephenmsft_4-1674118070442.png

It's a little hard to explain, but that's the way it is.

If you want to keep the expected output when you post, try to make your Name and FY from the Solutions table.

And you'll get the right output.

 

Rank = RANKX(FILTER(ALLSELECTED(Solution),[Solutions]=MAX('Solution'[Solutions])&&[Name]=MAX('Name'[Name])),CALCULATE(MAX('Time'[FY])),,ASC,Dense)
Rank2 = RANKX(FILTER(ALLSELECTED(Solution),[Name]=MAX('Solution'[Name])&&[Solutions]=MAX('Solution'[Solutions])),CALCULATE(MAX('Solution'[FY])),,ASC,Dense)

 

Both measures can return the right values.

vstephenmsft_6-1674118431558.png

 

 

Best Regards,

Stephen Tao

 

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

                                                                                                                                                         

 

tackytechtom
Super User
Super User

Hi @riishabhzz ,

 

Here a solution for a DAX measure:

tackytechtom_0-1673638534707.png

 

Measure = 
RANKX(
    ALLSELECTED ( 'Table' ),
    CALCULATE ( 
        MAX ('Table'[FY] ), 
        MAX ('Table'[solutions] ) = 'Table'[solutions]
    ), 
    , DESC
    , DENSE 
) 

 

 

I used the DAX ranking code example from here.

 

A quick clarification: Both solutions - whether you are creating a calculated column or a measure - is based on the coding language DAX 🙂 So, if you are asking for a help in DAX, one might provide you with a solution either way.

 

Let me know if this solved your issue!

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi @tackytechtom 

 

i tried your dax but still its not working 😞

i have attached screen-snip for your refrence

riishabhzz_0-1673712379482.png

 

if possible please teach /guide me how to do it 🙂

thank you 

Hi @riishabhzz ,

 

Could you try this?

Measure 2 = 
VAR _value = MAX('Table'[solutions] ) 
RETURN
RANKX(
    ALLSELECTED ( 'Table' ),
    CALCULATE ( 
        MAX ('Table'[FY] ), 
        _value = 'Table'[solutions]
    ), 
    , DESC
    , DENSE 
) 

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

tackytechtom
Super User
Super User

Hi @riishabhzz ,

 

Here a solution for a DAX measure:

tackytechtom_0-1673638534707.png

 

Measure = 
RANKX(
    ALLSELECTED ( 'Table' ),
    CALCULATE ( 
        MAX ('Table'[FY] ), 
        MAX ('Table'[solutions] ) = 'Table'[solutions]
    ), 
    , DESC
    , DENSE 
) 

 

 

I used the DAX ranking code example from here.

 

A quick clarification: Both solutions - whether you are creating a calculated column or a measure - is based on the coding language DAX 🙂 So, if you are asking for a help in DAX, one might provide you with a solution either way.

 

Let me know if this solved your issue!

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

tackytechtom
Super User
Super User

Hi @riishabhzz ,

 

Here a solution in DAX for a calculated column:

tackytechtom_0-1673548830844.png

 

Here the DAX code:

Column = 
RANKX ( 
    FILTER ( 
        'Table', 
        'Table'[solutions] = EARLIER ( 'Table'[solutions] )
    ),
    'Table'[FY],
    , DESC
    , DENSE
)

I used the DAX ranking code example from here.

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/

 



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi @tackytechtom ,

 

thanks for your help , but this solution is not working .

i am getting below error :-

i found out that earlier is EARLIER and EARLIEST are usually used in calculated column.

and we can't make caluclated column as it's a live connection so only dax is the solution .

here is the dax :-
dax = RANKX (
    FILTER (
        Solution,
       Solution[Solution Name]= EARLIER(Solution[Solution Name])
    ),
    'Solution'[Created On Fiscal Year],
    , DESC
    , DENSE
)

riishabhzz_0-1673586360146.png

riishabhzz_2-1673586890415.png

 

any help will be appreciated 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.