Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Oros
Post Prodigy
Post Prodigy

Monthly comparison over years

Hello.

 

I have a month comparison (last year LY and current year CY).  I have a data starting NOV 2021.  How do you make the month comparison start in NOV 2021 instead of JAN 2022.  How do you compare (monthly, year over another year) based on last X months?  Thanks.

Oros_0-1654093012767.png

 The measures applied for LAST YEAR'S and CURRENT YEAR

Oros_1-1654093225857.png

 

There is also a separate DATE TABLE created using a query:

Oros_2-1654093327561.png

 



 

8 REPLIES 8
v-kkf-msft
Community Support
Community Support

Hi @Oros ,

 

Please try the measure.

 

Rolling x months = 
VAR x = 3
RETURN
    CALCULATE (
        SUM ( 'SALES TABLE'[Sales] ),
        DATESINPERIOD ( 'DATE TABLE'[Date], MAX ( 'DATE TABLE'[Date] ), -1 * x, MONTH )
    )

 Screenshot 2022-06-07 152230.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-kkf-msft ,

 

Thank you for your reply.  How and where do you insert the ROLLING X MEASURE in this matrix table?

 

Oros_0-1654614820909.png

 

Hi @Oros ,

 

I simply add the measure and Sales to the Values field of the matrix, and I switch the value to rows in the attribute for easier comparison.

 

vkkfmsft_0-1654764893098.png

vkkfmsft_1-1654764968183.png

vkkfmsft_2-1654765157130.png


If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hello @v-kkf-msft ,

 

Thank you for your reply.  I just realized that your solution if ROLLING X MONTHS.  What I was looking for was simply to start the month-to-month comparison from NOVEMBER 2021 to NOVEMBER 2022, instead of January-January.  Is there a way to show each month starting November 2021? Thanks again.

Hi @Oros ,

 

I am not sure if I understood your question correctly. If you only need to compare data in the range 2021-11 to 2022-11, please try

 

Rolling x months = 
VAR x = 3
VAR diff =
    CALCULATE (
        SUM ( 'SALES TABLE'[Sales] ),
        DATESINPERIOD ( 'DATE TABLE'[Date], MAX ( 'DATE TABLE'[Date] ), -1 * x, MONTH )
    )
VAR SelectDate =
    FORMAT ( MAX ( 'DATE TABLE'[Date] ), "yyyymm" )
RETURN
    IF ( SelectDate >= "202111" && SelectDate <= "202211", diff )

 

Best Regards,
Winniz


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

abusen333
Frequent Visitor

OK So the idea is adding new colums to your calendar table and slice by them , same as fiscal year . 

note ;

please dont forget to change the current column to the new colum in your dax measre .

 

Hi @abusen333 ,

 

So how do you excatly do that?  Thanks.

IT will be easy for to provide example of you problem in power BI format.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors