Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Issue with medianx

Hi all , 

 

I have the following problem . I am have 3 columns . Two has values and one has locations . 

I divide value1/value2 and i need to calculate the median per location and the total median . 

 

1) If i create a calculated column C1 and then create a mesaure C2=median(C1)  i get as result V1 

 

2) if i create the following measures S1=sum(value1) , S2=sum(value2) , S3=divide(S1,S2) and then

 

S4=MEDIANX(KEEPFILTERS(VALUES('Sheet1'[Locations])),(S3)) i get as result V2 

 

3) if i skip creating measures S1,S2,S3 and do all the calculations inside one measure as the above 

 

S5=MEDIANX(KEEPFILTERS(VALUES('Sheet1'[Locations])),(SUM(Sheet1[value1])/SUM(Sheet1[value2])) i get as result V3
 
For cases 2& 3 if i create a matrix with the locations and the median per location is the same but the totals differs . V3 is almost double of V2 .  V1 is completly different . 
 
***On V1 i keep manually the same filters with the others 2 . 
 
I tried dax studio to understand how powerbi executes the query
 
For S4:
 
Query
SELECT 'Sheet1'[Locations], SUM ( 'Sheet1'[V1] ), SUM ( 'Sheet1'[V2] ) FROM 'Sheet1';   
 
 For S5:
 
Query
SELECT SUM ( 'Sheet1'[V1 ), SUM ( 'Sheet1'[V2] ) FROM 'Sheet1';   
 
 
Can someone help me to understand why i get 3 different results ? 
 
Thank u!
 

2 Replies