Showing results for 
Search instead 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 = 
    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,



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 ?

Super User
Super User

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

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
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!

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

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

Helpful resources

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors