Forum Discussion

NKD's avatar
NKD
Frequent Visitor
1 year ago
Solved

Difference between measure and total

Hello,   I'm having a weird result and got no idea why. I have a sales table with a calendar date, a calendar table with 1-* simple relationship. These are the fields: Chiffre d'Affaires = sum(...
  • danextian's avatar
    1 year ago

    Hi NKD 

     

    Assuming today's date doesnt' necessarily mean today but the latest date with data in your semantic model, try this:

    Cumulative LY with a stop = 
    VAR _lastdate =
        CALCULATE (
            LASTNONBLANK ( CalendarTable[Date], [Sales Amount] ),
            ALLSELECTED ( CalendarTable )
        )
    RETURN
        CALCULATE (
            CALCULATE ( [Cumulative CY], SAMEPERIODLASTYEAR ( CalendarTable[Date] ) ),
            KEEPFILTERS ( CalendarTable[Date] <= _lastdate )
        )
    

     

    Please see the attached pbix.