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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
A_a_a
Helper III
Helper III

Measure with selectedvalue works but when I want to sort the selected values it stops working...

Hi All,

 

I have one measure with Selectedvalue measure.

Everything is ok, but when I want to sort the column which i use in the Selectedvalue measure, it stop working and the output is incorrect.

 

Please see my measures:

1) Selected A = SELECTEDVALUE('Table1'[A])
 
2) ABCD =
var v=[Selected A]
var c1 = calculate(sum('Table1'[Time]),'Table1'[Activity] = "Run",'Table1'[A]=v)
var c2 = calculate(sum('Table1'[Time]),'Table1'[Activity] = "Run",All('Table1'[A]))
var cfin= divide(c1,c2,0)
var ctotal = divide(c2,calculate(sum('Table1'[Time]),All('Table1'[A]),All('Table1'[Activity])),0)

var output = IF(COUNTROWS(VALUES('Table1'[A]))=1,cfin,ctotal)

return output
 
Measures work properly, but when I want to sort A by another column just to change the order, in all cells the output is 100 % (except Total - in both scenarios Total figure is correct).
 
Please help.
 
Thanks,
G.
3 REPLIES 3
amitchandak
Super User
Super User

@A_a_a , Try like

 

ABCD =
var v=[Selected A]
var c1 = calculate(sum('Table1'[Time]),filter('Table1', 'Table1'[Activity] = "Run" && 'Table1'[A]=v))
var c2 = calculate(sum('Table1'[Time]),filter('Table1', 'Table1'[Activity] = "Run"),All('Table1'[A]))
var cfin= divide(c1,c2,0)
var ctotal = divide(c2,calculate(sum('Table1'[Time]),All('Table1'[A]),All('Table1'[Activity])),0)

var output = IF(COUNTROWS(VALUES('Table1'[A]))=1,cfin,ctotal)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Thank you for that.

Unfortunately, now it shows 100 % everywhere, even before sort by column...

 

 

Hi @amitchandak 

 

I think the issue is with Selected A = SELECTEDVALUE('Table1'[A]) -

by default in matrix table i can see:

 

A

0

1

2

3

4

...

23

 

but I need to see it as:

6

7

8

9

...

5

 

I created an additional column so I can sort the numbers in order that I need, but then the output of ABCD measure is incorrect (100% everywhere).

Is there any solution that I can have measure SELECTEDVALUE sorted by another column... because 'sort by column' is providing wrong calcuations.

A_a_a_0-1678114916169.png

 

Thanks,

G.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.