Forum Discussion

OneWithQuestion's avatar
OneWithQuestion
Post Prodigy
7 years ago
Solved

How to write PREVIOUSMONTH manually without builtin function?

I need the functionality of PREVIOUSMONTH, but I am not using it against months.  Instead I am looking at custom intervals (usually, but not always every 2 weeks).   There is a column in the date t...
  • TomMartens's avatar
    7 years ago

    Hey,

     

    I guess this might be something you are looking for:

    Value of Previous Interval = 
    var maxRunningIndex = MAX('Dimension Date'[Interval])
    return
    CALCULATE(
        <the expression>
        ,FILTER(
            ALL('Dimension Date')
            ,'Dimension Date'[Interval] = maxRunningIndex - 1
        )
    )

    The assumption behind this is: the date table is related (on the one side) with the fact table (on the many side).

     

    Regards,
    Tom