Forum Discussion

Jnis's avatar
Jnis
Frequent Visitor
8 years ago
Solved

DAX: Calculate Previous Month Sum, doesnt work

Hey,
I tried to sum up some values out of the previous month, like this:

 

 

It is just an example for me, so I can practise DAX and learn it - but it doesnt work at all and I have absolutely no clue why It's not working.
Can you please give me some hints?

Thanks,
Jnis

  • Hi Jnis

     

    You should create the measure with your formula, then you will get the right output.

     

    Measure =
    CALCULATE ( SUM ( 'Table'[Gesamt] ), PREVIOUSMONTH ( 'Table'[Period] ) )

     

     

     

    For reference, you could have a good look at of this blog Understanding calculated column and Measures.

     

    Best Regards,

    Cherry

2 Replies

  • Hello,

     

    You can try:

    Calc=CALCULATE(SUM(...),PREVIOUSYEAR(...),ALL('Tabelle1'[Periode])

    Generally in such cases it is recommended to have separate DateTables to relate to.

    Your formula should then work perfectly as measure instead of calculated column.

     

    The structure of your Table isn't ideal for PowerPivot. You should check out Unpivot.

     

    Additionally: Here are two links for starters.

     

     

  • v-piga-msft's avatar
    v-piga-msft
    Icon for Resident Rockstar rankResident Rockstar

    Hi Jnis

     

    You should create the measure with your formula, then you will get the right output.

     

    Measure =
    CALCULATE ( SUM ( 'Table'[Gesamt] ), PREVIOUSMONTH ( 'Table'[Period] ) )

     

     

     

    For reference, you could have a good look at of this blog Understanding calculated column and Measures.

     

    Best Regards,

    Cherry