Forum Discussion

mbidelski's avatar
mbidelski
Helper I
2 years ago
Solved

Timeintelligence calculation group

Hi everyone,   I have a YoY calculation item     VAR PREV = CALCULATE ( SELECTEDMEASURE (), sameperiodlastyear ( '_CALENDAR'[Date]) ) RETURN IF(OR(ISBLANK(PREV),ISBLANK(SELECTEDMEASURE ())),BLA...
  • OwenAuger's avatar
    2 years ago

    Hi mbidelski 

    You could use LASTNONBLANK to identify the last date where SELECTEDMEASURE() is nonblank, then expand this to a month with PARALLELPERIOD.

     

    This should leave the left chart unchanged, but adjust the right chart to display just the latest month.

     

    Here is how I would write it.

    I slightly rewrote the final expression after RETURN, but you don't have to change that.

    -- Find the last month for which SELECTEDMEASURE() is nonblank
    VAR LastMonthAvailable =
        PARALLELPERIOD (
            LASTNONBLANK ( 'Date'[Date], SELECTEDMEASURE ( ) ),
            0,
            MONTH
        )
    VAR PREV =
        CALCULATE (
            SELECTEDMEASURE ( ),
            SAMEPERIODLASTYEAR ( LastMonthAvailable )
        )
    VAR CURR = CALCULATE ( SELECTEDMEASURE ( ), LastMonthAvailable )
    RETURN
        IF (
            AND ( NOT ISBLANK ( PREV ), NOT ISBLANK ( CURR ) ),
            DIVIDE ( CURR - PREV, PREV )
        )

    Does this work for you?

    Regards