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

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

Reply
cuongle
Advocate II
Advocate II

Cannot sort by measure based on another measure

I got stuck on how to sort by measure based on another measure. On my case I have 2 measures called: Savings and Spend.

 

measure.PNG

 

In order to support bar chart:

 

conextmenu.PNG

 

Whenever end-users choose 'Sort by Saving' I would like to sort by Spend behind the scene. I know Power BI support function called 'Sort By Column' on modeling but it's disable if I choose measure `Saving`

 

SortByColumn.PNG

 

Is there anyway to work around for this case?

 

Thanks a lot

6 REPLIES 6
Anonymous
Not applicable

Hi @cuongle,

 

I think this function only works on columns.(if you try to expand the dropdown panel, you can only find the columns)

 

Regards,

Xiaoxin Sheng

Thanks @Anonymous, do you know is there any way to work around with this? I cannot use column as measure `Spend` and `Savings` is dynamically calculated based on the currency that user chooses.

Anonymous
Not applicable

Hi @cuongle,

 

Can you share some detail contents about this formulas and table structures? If these measures not the dynamic measure which changes by slicer, you can modify the formula to transform it to calculate column.


Regards,

Xiaoxin Sheng

@Anonymous

 

Assume I have table called InvoiceDetail, which contain column:

 

SpendInEUR

SpendInGBP

SpendInUSD

SavingsInEUR

SavingsInGBP

SavingsInUSD

 

So on the Power BI, we allow user chooses which currency they want to show using ChicletSlicer like that:

 

Capture.PNG

 

And then we calculate measure Spend and Savings based on which currency is opted

 

 

Spend = 
IF (
    LASTNONBLANK ( 'DefaultCurrency'[Code], 1 ) = "GBP",
    SUM ( InvoiceDetail[SpendInGBP]),
    IF (
        LASTNONBLANK ( DefaultCurrency[Code], 1 ) = "USD",
        SUM ( InvoiceDetail[SpendInUSD] ),
        SUM ( InvoiceDetail[SpendInEUR] )
    )
) 
Savings = 
IF (
    LASTNONBLANK ( 'DefaultCurrency'[Code], 1 ) = "GBP",
    SUM ( InvoiceDetail[SavingsInGBP]),
    IF (
        LASTNONBLANK ( DefaultCurrency[Code], 1 ) = "USD",
        SUM ( InvoiceDetail[SavingsInUSD] ),
        SUM ( InvoiceDetail[SavingsInEUR] )
    )
)

 

Thanks for your help

 

 

 

 

@cuongle Did you ever find a trick to work around this? I am dealing with the exact same situation.

Anonymous
Not applicable

Hi @cuongle,

 

Power bi not support dynamic calculated column/table based on slicer, so it is impossible to convert your formula to calculate column.

 

Reference link:

Calculated Column/Table Change Dynamically According to Slicer Selection in the Report.

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
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.

Top Kudoed Authors