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.
Hello,
I am writing a DAX query and my dataset is following.
Table = DATATABLE (
"Account#", INTEGER,
"total", DOUBLE,
{
{ 980012, 1200 },
{ 980012, 1200 },
{ 980012, 1200 },
{ 980012, 1300 },
{ 980013, 5000 },
{ 980013, 5000 },
{ 980013, 7800 }
}
)
Account# | total |
980012 | 1200 |
980012 | 1200 |
980012 | 1200 |
980012 | 1300 |
980013 | 5000 |
980013 | 5000 |
980013 | 7800 |
I was wondering if there is a way to create a M like indexing through a calculated column (not meaure) in this table like following. I want to rank the total by Account#-total combined category.
Account# | total | Rank |
980012 | 1200 | 1 |
980012 | 1200 | 2 |
980012 | 1200 | 3 |
980012 | 1300 | 1 |
980013 | 5000 | 1 |
980013 | 5000 | 2 |
980013 | 7800 | 1 |
I am trying to do this on a temp table through DAX query so I can't go back to M and create an index.
So far I tried this.
Is there a way to achieve the desired ranking by any chance in DAX query?
Thank you in advance.
Solved! Go to Solution.
Perhaps you could add another column, and in that column use the RAND() function to add a small decimal amount to each total. Then you rank on that column (which should have fewer chances of having a duplicate value), but display the real total column.
Help when you know. Ask when you don't!
Refer if this can help
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
Perhaps you could add another column, and in that column use the RAND() function to add a small decimal amount to each total. Then you rank on that column (which should have fewer chances of having a duplicate value), but display the real total column.
Help when you know. Ask when you don't!
@kentylerthanks it worked.
I do have a follow-up question for you though out of curiosity. Once RAND() values are obtained in step 1 is there a way to stop that from evaluating agin in subsequent steps/
I don't understand your question. RAND has to be called for each row or the value it adds will not be different, and thus not able to provide a tie breaker.
Help when you know. Ask when you don't!
Let me clarify
the rand column value in VAR _3 is different than VAR_2.
Is there a way to keep the value of "rand" column obtained in VAR_2 unchanged in VAR_3?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |