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
ramiouanes
Advocate I
Advocate I

Sort Matrix and Chart with KPI Values

Hello,

 

I have a SSAS tabular model with a Time Analysis dimension and a KPI dimension.

The KPI Dimension contains members with values of type: Sales, Budget...etc.

The Time Analysis Dimension contains members of type: Periodic, YTDN, YtDN-1...etc.

 

I have one measure in the model with an IF statement based on both KPI and Time Analysis dimensions. So for example to calculate Periodic Sales, I have an expression containing " IF( KPI[Name]="Sales" && TimeAnalysis[Name]="Periodic"; calculate(sum(Fact[valueColumn]); Filter( Fact[KPIColumn]="Sales"));Blank()); "

 

What I want to achieve eventually is a sort on the matrix column based on Sales Amount. So the table would be something like this: 

 

Rows: Month

Columns: KPI/TimeAnalysis

Values: Value

 SalesBudget
MonthPeriodicYTDNYTDN-1PeriodicYTDNYTDN-1
January 1010510105
February31345156
March4004134539040545

 

 

And I want to be able to sort the matrix with the values from the Sales/YTDN Column to obtain something like this:

 

Sort by column in Red:

 SalesBudget
MonthPeriodicYTDNYTDN-1PeriodicYTDNYTDN-1
January 4004134539040545
February1010510105
March31345156

 

 

Same thing for a chart, where I have Month in axis, Time Analysis in Legend and Value in values and I want to sort the chart by Sales/YTDN value. 

 

 

Is there a way to achieve this? Thanks in advance for any input.

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi ramiouanes,

 

" IF( KPI[Name]="Sales" && TimeAnalysis[Name]="Periodic"; calculate(sum(Fact[valueColumn]); Filter( Fact[KPIColumn]="Sales"));Blank()); "

 

<--- Does this mean you want to create two slicer charts based on KPI[Name] column and TimeAnalysis[Name] column? And if user select "Sales" and "Periodic", return value of calculate(sum(Fact[valueColumn]); Filter( Fact[KPIColumn]="Sales"))? If so, you should modify your measure like pattern below:

Measure =
IF (
    SELECTEDVALUE ( KPI[Name] ) = "Sales"
        && SELECTEDVALUE ( TimeAnalysis[Name] ) = "Periodic",
    CALCULATE (
        SUM ( Fact[valueColumn] ),
        FILTER ( Fact, Fact[KPIColumn] = "Sales" )
    ),
    BLANK ()
)

In addtion, to sort values in a column, just right click on the column then click "Sort".

 

Regards,

Jimmy Tao

Hello @v-yuta-msft,

 

Actually, I'm not trying to put a slicer for the measure.

 

It's a matrix that I'm using with KPI and Time analysis as columns and a column Value (That contains the sum of all my KPIs) as values.

 

The sort does not work though. The idea is to be able to sort only one KPI. And the KPI here are grouped in one column which is KPI[Name]. So the right click/Sort doesn't work.

 

 

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.