Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Average and sum Dax

Hi All,

I have issues with to get the Divide and Sum Function. Please look into the sample model below

Table

Mat             code           Sales 

12              a1                  10

12              a1                  20

12              a1                  30

12              b1                  40

12              b1                  50

12              b1                  50

13              c1                   70

13              c1                   80

13              d1                   90

13              d1                  100

 

 

Result Table
Mat          Sales   

12              100              Logic :(10+20+30+40+50+50)/2( distinct count of "Code",   i.e. a1 & b1)

13              170     

Total        270

 

i tried to do sum of averages here, but getting a different result in total


Hope im making sense here

 

Thanks in advance !

Vinay

                     

  • Hi,

    Write these measures:

    Total Sales = SUM(Data[Sales])

    Number of codes = DISTINCTCOUNT(Data[code])

    Measure = SUMX(VALUES(Data[Mat]),[Total sales]/[Number of codes])

    Hope this helps.

7 Replies