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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.