Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Combine Slicer (Date from...until...) and function 'prevoiusmonth'

Hi folks,

 

i have a question about slicers and the function „previousmonth“. I calculated flexitime (starts in 2003 until today). I use a date slicer, which shows date from (2003-01-01) until date (2019-11-15). I would like to see flexitime at the same date just the previous month (2019-10-15).

I tried this measure:

 

Flexitime last Month = CALCULATE([Flexitime];PREVIOUSMONTH(Kalender[Datum])

 

Unfortunately I get a empty column.

 

Does anybody can help me?

 

Thanks for your help

freiburgc

  • Anonymous's avatar
    Anonymous
    6 years ago

    Thanks for your answer RobbeVL!

     

    I found an answer:

     

    Flextime last month =CALCULATE([flextime];DATEADD(Calendar[Date];-1;MONTH))

2 Replies

  • RobbeVL's avatar
    RobbeVL
    Impactful Individual

    Hi,

    When you use PREVIOUSMONTH, it actually returns the value of the complete previous month.

    The function Previousmonth on a day level does not exist. This is because the different of numbers of days per month differs. 

     

    What is your expected output wheb you want last month of 30/03/2019

     

    Also I dont know what your data is about, but comparing the monthnumbers is usually not very insightfull. 

    Try having a look at weeknumbers ? 

     

    Although it is not impossible to create what you requested.

     

    Have a look here:


    https://community.powerbi.com/t5/Desktop/PREVIOUSMONTH/td-p/13307

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your answer RobbeVL!

       

      I found an answer:

       

      Flextime last month =CALCULATE([flextime];DATEADD(Calendar[Date];-1;MONTH))