Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
So I has got a Fact table and had a measure to calculate the monthly sales ratio by a category group.
Next I wanted to know the rank from highest to lowest ratio for the particular category but below is the ranking that I got from this DAX formula :
Related ItemGroupID | InvoiceAmt Sum Perc | Ratio Itemgroup Sales Rank | Measure | Month |
EXTERNAL | 57 | 2 | Jan | |
FOC | 4 | Jan | ||
METAL | 15 | 3 | Jan | |
PLASTIC | 28 | 2 | Jan |
Solved! Go to Solution.
Hi @keithchai
You can create a Measure to get the result you want.
Rank =
VAR res =
RANKX (
ALLEXCEPT ( FactInvoice, FactInvoice[Month] ),
CALCULATE (
[InvoiceAmt Sum Perc],
ALLEXCEPT ( FactInvoice, FactInvoice[Related ItemGroupID], FactInvoice[Month] )
),
,
DESC,
DENSE
)
RETURN
IF ( HASONEFILTER ( FactInvoice[Related ItemGroupID] ), res, BLANK () )
The result looks like this:
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @keithchai
You can create a Measure to get the result you want.
Rank =
VAR res =
RANKX (
ALLEXCEPT ( FactInvoice, FactInvoice[Month] ),
CALCULATE (
[InvoiceAmt Sum Perc],
ALLEXCEPT ( FactInvoice, FactInvoice[Related ItemGroupID], FactInvoice[Month] )
),
,
DESC,
DENSE
)
RETURN
IF ( HASONEFILTER ( FactInvoice[Related ItemGroupID] ), res, BLANK () )
The result looks like this:
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@keithchai , what is your base data, what was shown in the last table ?
Try like
Rank = RANKX( ALLselected(FactInvoice ) , CALCULATE( [InvoiceAmt Sum Perc] , ALLEXCEPT( FactInvoice , FactInvoice[Related ItemGroupID], NHFCalendar[Month])), , DESC, Dense)
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Hi @amitchandak ,
I tried changed to ALLSELECTED the result is not desired.
The rank now is ranking on the entire year, I only wanted to know the rank for the categories within the month.
ALLSELECTED Result:
My desired output:
My base data is just a simple fact invoice table, with the sales amount for the invoices throughout the year.
InvoiceAmt Sum Perc is the percentage of invoiceamt sum for the month. Say January is 57% of the total sales and 58% for March total sales etc. If possible I may not want to share the pbix file, my company is a little strict. 😫
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
92 | |
86 | |
85 | |
67 | |
49 |
User | Count |
---|---|
139 | |
113 | |
104 | |
64 | |
60 |