Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Previous Month in Direct Query Mode

Hi Experts   I am struggling to get the previous month DAX Measure to Work in DQ Mode. My measure is Internet Sales last Month = CALCULATE( [Internet Sales], PARALLELPERIOD( DimDa...
  • Greg_Deckler's avatar
    4 years ago

    Anonymous As aj1973 stated, TI functions have limitations with DQ, which is one of the reasons I find them generally useless. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

     

    In your case, you could get previous month this way:

    Internet Sales last Month measure = 
      VAR __Date = MAX('DimDate'[FullDateAlternateKey])
      VAR __LastMonthEnd = EOMONTH(__Date,-1)
      VAR __LastMonthBegin = DATE(YEAR(__LastMonthEnd),MONTH(__LastMonthEnd),1)
    RETURN
    CALCULATE(
        [Internet Sales],
        DimDate[FullDateAlternateKey] >= __LastMonthEnd,
        DimDate[FullDateAlternateKey] <= __LastMonthBegin
    )