Forum Discussion

afbraga66's avatar
afbraga66
Helper III
5 years ago

Sort Matrix by dynamic column value based on filters

Hi,

 

I have a requirement to sort a matrix by the last possible month value, 7 in the example below. The issue is that Power BI only sorts by the total and that is not what I want.

 

 

I want it to look like the image below, i.e. sorted by the values where month equals 7, because it is the latest with the filters I have.

 

I did it with this formula:

 

Today Month = CALCULATE([mDuration(min)], KEEPFILTERS(DOWNTIME[MES_FABRIL]=MONTH(TODAY())))

 

The problem is that it is fixed to todays month, and I can't have it like that. I want it to have the dynamic filtering according to if I select 1 month, 2 months or none. If I select 5 and 6, then 6 should be the one being used for sorting since it is the latest. If I don't select anything then it is 7. Can you please help me making it dynamic?

Check the pbix file with the example above. PBI Test example 

 

Thank you.

 

Best regards,

André

11 Replies