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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gaalee89
Regular Visitor

Sort by the second column with the field

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

gaalee89_1-1632383263450.png

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.

gaalee89_3-1632383811393.png

 

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
amitchandak
Super User
Super User

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

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

Animation4.gif

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

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.