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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Update with Sales Adjusted

I have below measure to rank customers by sales:

 

Sales Amt =
Var SalesOfAll=
    CALCULATE([Total Sales],REMOVEFILTERS(Groupcustomer[Groupcustomer]))
Return
    IF(
        ISINSCOPE(Groupcustomer[Groupcustomer]),
        VAR ProductsToRank = 'TopN'[Value for TopN]
        VAR IsOtherSelected = SELECTEDVALUE(Groupcustomer[Groupcustomer])="Others"
        VAR ProductsWithSalesAmt =
            ADDCOLUMNS(
                ALLSELECTED(Groupcustomer[Groupcustomer]),
                "@Amt", [Total Sales]
            )
        VAR Top3Prods = TopN (ProductsToRank,ProductsWithSalesAmt,[@Amt])
        VAR SalesOfTop3 = SUMX(Top3Prods,[@Amt])
        VAR Result = IF(IsOtherSelected,SalesOfAll-SalesOfTop3,[Total Sales])
        Return Result,
        SalesOfAll
    )
 
Where Groupcustomer is: 
Groupcustomer=
UNION(
    ALLNOBLANKROW('Sales Autoupdate'[Groupcustomer]),
    {"Others"}
)
 
I have added a source called sales adj. where I do some adjustment between dates in a manual excelsheet. I have added to sales into "Total Sales" but dont get the ranking correctly. I think I need to add the new source to Groupcustomer like below but doesnt get it to work
 
Groupcustomer=
UNION(
    ALLNOBLANKROW('Sales Autoupdate'[Groupcustomer] + 'Sales Adj'[Groupcustomer] ),
    {"Others"}
)
 
All support appreciated
 
2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

I think you can use the rankx function for comprehensive sorting, if you can, share your sample data to better solve the problem for you.RANKX function (DAX) - DAX | Microsoft Learn

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

MVenables
Advocate II
Advocate II

Hi,

 

Just to get an idea of where you are going with this. Could you not just add your Sales measure to the filter pane and advance filter by Top N? As per my example below. Seems quite complex for what you might be trying to achieve. Correct me if im wrong

MVenables_0-1711368100754.png

Thank you

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.