Forum Discussion

Uzi2019's avatar
Uzi2019
Community Champion
5 years ago
Solved

Incorrect Previous month value calculation

Hi Community,   I am trying to create previous month values. Everything is working as expected only issue is last date in Database is 5th April 2021 but when I select Date range slicer from 1st to ...
  • v-kkf-msft's avatar
    5 years ago

    Hi Syndicate_Admin ,

    I create the following sample data, and then create a measure.

     

    Ventas anteriores = 
    var MonthEnd = 
        CALCULATE(
            SUM('DataTable'[Sales]),
            DATEADD( 'Calendar'[Date], -1, MONTH )
        )
    var Month = 
        CALCULATE(
            SUM('DataTable'[Sales]),
            FILTER(
                ALL('DataTable'),
                'DataTable'[Date] <= EDATE( MAX('Calendar'[Date]), -1 )
                &&'DataTable'[Date] >= EDATE( MIN('Calendar'[Date]), -1 )
            )
        )
    var Result = 
        IF(
            MAX('Calendar'[Date]) = EOMONTH( MAX('Calendar'[Date]), 0 ), 
            MonthEnd, 
            Month
        )
    return Result
    

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

    Best Regards,
    Winniz

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.