Forum Discussion

gdexter's avatar
gdexter
Frequent Visitor
8 years ago
Solved

Comparing selected month automatically with previous month

Hi Power BI community,

 

I need your help!

 

Would like to select a date range using slicer and then have a two tables below. One which shows data for the selected month, and one which dynamically adjusts to show data from month before the selected time.

 

Below is an image of what I am trying to achieve.

 

EXTRA INFO:

Will briefly describe what I have tried to do so far.

I have created a new date column that has all the dates offset backwards by one month in relation to my original date column. I assumed I could then add the "daily-1month" data to the visual labelled two months ago. I tried, shown below and nothing changed.

 

Here is the DATA view for date columns

 

Yours,

Gdexter

  • Hi gdexter,

     

    Based on my understand for your requirement, I made a test.

     

    You could create two measures like below.

     

    current date = CALCULATE(SUM('table'[Sales]))

    last month = CALCULATE(SUM('table'[Sales]),DATEADD('table'[Date],-1,MONTH))

    So that you could get the output below.

     

    For more details, you could have a reference of this attachment.

     

    If you still need help, please share some data sample witch could reproduce your scenario, so that we can help further investigate on it?

     

    Best  Regards,

    Cherry

2 Replies

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi gdexter,

     

    Based on my understand for your requirement, I made a test.

     

    You could create two measures like below.

     

    current date = CALCULATE(SUM('table'[Sales]))

    last month = CALCULATE(SUM('table'[Sales]),DATEADD('table'[Date],-1,MONTH))

    So that you could get the output below.

     

    For more details, you could have a reference of this attachment.

     

    If you still need help, please share some data sample witch could reproduce your scenario, so that we can help further investigate on it?

     

    Best  Regards,

    Cherry

    • gdexter's avatar
      gdexter
      Frequent Visitor

      Hi Cherry,

       

      Thanks for the advice and apologies for my lateness in getting back to you.

       

      The pie chart I attached above is calculated by measuring the number of occurences of the word "EARLY", "LATE" and "ONTIME". These are non-numerical values, so I used COUNT in the place of where you used SUM. 

       

      Then it worked fine, thanks very much!

       

      Best,

      Gdextor