cancel
Showing results for
Did you mean:
Regular Visitor

## Sort by the second column with the field

Hi, i'm stuck. I have this table :

It's a visual table containing some field from my unique table model. And measures which are TauxMarge, VarTM and VarTM_Note.

Code for the measure VarTM_Note : It return a rating acording to the value of the variation.

``````VarTM_Notenb =
SWITCH(
TRUE(),
ABS([VarTM]) >= 0.1, 5,
ABS([VarTM]) >= 0.05 && ABS([VarTM]) < 0.1 , 4,
ABS([VarTM]) >= 0.03 && ABS([VarTM]) < 0.05 , 3,
ABS([VarTM]) >= 0.01 && ABS([VarTM]) < 0.03, 2,
1
)``````

I need to sort this visual table by this measure somehow. But when i try to do it, it take the first column where VarTM_Note is (red). But i only want to sort it by second one (green), because the first one is useless and will be hidden due to the fact that it try to measure a variation and give it a rating on the first year of my data.

This is the source table that i use to create part of this visual table :

What would be the best way to go about it ?

3 REPLIES 3
Super User

@gaalee89 , is it a table of matrix. On matrix you can sort on column or mesure total

Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
Regular Visitor

@amitchandak it is a table of matrix, but may i ask you to show me how to sort on a measure total in this case ?

I tried it this way :

But Power BI doesn't seem to correctly calculate the result for neither of the measures VarTM and VarTM_Note. Probably because i use the PREVIOUSYEAR method i would assume.

``````VarTM =
var TMI = [TauxMarge]
var TMcalc = [TauxMarge] - CALCULATE([TauxMarge] , PREVIOUSYEAR('model'[Date]))
RETURN IF(TMI = TMcalc,0, TMcalc)``````

I thought about an other measure that can calculate this result on itself but i can't think on how to properly do it.

Community Support

Hi.  @gaalee89

From your screenshot, the row total value of VarTM_Notenb seems to be incorrect.

You can try to add a new measure as below  and then sort by this field in matrix.

``VarTM_Notenb_2 = SUMX('Table',[VarTM_Notenb])``

If it doesn't work, please  share a sample file for further research.

Best Regards,
Community Support Team _ Eason

Announcements