Forum Discussion

tamiribas's avatar
tamiribas
Resolver I
2 years ago

Sum per Department in DAX (Window function)

Hi

I am trying to create a measure that will calculate the amount of days per department.

The 4th column shows the result which is not what I want.

 

Days Per Department = 
CALCULATE(
    [Total Days],
    WINDOW(
        1,ABS,-1,ABS,
        SUMMARIZE(ALLSELECTED(data), data[Dept], data[Index]),
        PARTITIONBY(data[Dept]))
)

 The result should be 4 for A, 3 for B and 5 for C

 

Appreciating any advise,

 

Thank you,

Tamir

 

2 Replies

  • tamiribas,

     

    Try this measure:

     

    Days Per Department =
    CALCULATE ( [Total Days], ALL ( data ), VALUES ( data[Dept] ) )

     

     

  • Hi DataInsights 

    Thank you for the suggestion, however, I was looking to understand why the WINDOW function does not work as expected.

    Thank you,

    Tamir