Forum Discussion

abhiiimr15's avatar
abhiiimr15
Frequent Visitor
7 years ago

DAX on Median Calculation

Hi,

I am struggling with DAX wherein I would like to know the Median Price and Max Price of the set of products from the following data set.

Avg. Cost of the region will be per region ID and is displayed in Avg. Cost in region colum. (=Cost/Product COunt).

Also, Median Price I would like to calculate across all regions

And also the Max Price across all regions.

Any help???

 

Region IDCostProduct CountAvg. Cost in region
4770208111
8439382448222.18
393862202893.11
11043926115442.61
2905757320102
3449393164232.78
8109525322131.69
3886453620111.82
6976799867262.58
77824349212
19635856522.5
2399631749163.06
95955920522.5
719186711042.5
537416792173
7346700845172.65
93243941942.25
514721161662.67
417901212
7897329747162.94
30917529522.5
1965506637123.08
3172795145222.05
75585923723.5
965040192683.25
98073814321.5
67489965193.42
37642492522.5
70617906522.5

3 Replies

  • AlB's avatar
    AlB
    Icon for Community Champion rankCommunity Champion

    Hi abhiiimr15 

    Not sure I understand fully. Once you have Avg. Cost in region, would it suffice to create two new measures?

     

    MedianPrice = MEDIAN(Table1[Avg. Cost in region])
    

    and

     

    MaxPrice = MAX(Table1[Avg. Cost in region])

     

    • abhiiimr15's avatar
      abhiiimr15
      Frequent Visitor

      'm sorry if I was not very clear. Actually my requirement is at the following level

       

      Below is the data table of the above screen shot. 

       

      Super GeoCountryRegion IDCostProduct CountAvg. Cost in regionMedian at Country levelMedian at Super Geo levelMax Price at Country levelMax Price at Super Geo level
      A14770208111                                    2.18                                        2.34                                        3.11                                            3.11
      A18439382448222.18    
      A1393862202893.11    
      A111043926115442.61    
      A12905757320102    
      A23449393164232.78    
      A28109525322131.69                                    2.50 3.06 
      A23886453620111.82    
      A26976799867262.58    
      A277824349212    
      A219635856522.5    
      A22399631749163.06    
      A295955920522.5    
      B3719186711042.5                                    2.58                                        2.58                                        3.00                                            3.08
      B3537416792173    
      B37346700845172.65    
      B393243941942.25    
      B4514721161662.67                                    2.59 3.08 
      B4417901212    
      B47897329747162.94    
      B430917529522.5    
      B41965506637123.08    
      B43172795145222.05    
      C575585923723.5                                    2.88                                        2.88                                        3.50                                            3.50
      C5965040192683.25    
      C598073814321.5    
      C567489965193.42    
      C537642492522.5    
      C570617906522.5    
      • AlB's avatar
        AlB
        Icon for Community Champion rankCommunity Champion

        You can still use the measures above in table visual where you need to place in rows the level you want to look at: Country or Super Geo