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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
sraj
Responsive Resident
Responsive Resident

Year & month comparision

Hi everyone,

Is there anyway to show the difference between years?  Both Years/Months are in the same table, can someone please advise?

 

Capture.PNGCapture 2.PNG 

1 ACCEPTED SOLUTION

Hi @sraj,

 

You can try measure as:

Measure = 
IF(
    HASONEVALUE('Table'[Date]),
    MAX('Table'[Sales]),
    CALCULATE(
        MAX('Table'[Sales]),
        FILTER(
            'Table',
            YEAR('Table'[Date])=2021)
    )-
    CALCULATE(
        MAX('Table'[Sales]),
        FILTER(
            'Table',
            YEAR('Table'[Date])=2020)
    )
)

Here is the output:

vxulinmstf_0-1626832229371.png

The pbix is attached.

 

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

View solution in original post

6 REPLIES 6
v-xulin-mstf
Community Support
Community Support

Hi @sraj,

 

Is this what you want?

vxulinmstf_0-1626769150716.png

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

sraj
Responsive Resident
Responsive Resident

Yes, exactly this but the difference not the total.

Hi @sraj,

 

You can try measure as:

Measure = 
IF(
    HASONEVALUE('Table'[Date]),
    MAX('Table'[Sales]),
    CALCULATE(
        MAX('Table'[Sales]),
        FILTER(
            'Table',
            YEAR('Table'[Date])=2021)
    )-
    CALCULATE(
        MAX('Table'[Sales]),
        FILTER(
            'Table',
            YEAR('Table'[Date])=2020)
    )
)

Here is the output:

vxulinmstf_0-1626832229371.png

The pbix is attached.

 

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

sraj
Responsive Resident
Responsive Resident

Got it, thank you very much for your help!

Ashish_Mathur
Super User
Super User

Hi,

In the Row labels, show only the Month (not YearMonth).  Furthermore, you should have a Calendar Table with a relationship from the Date column of your Data Table to the Date column of your Calendar Table.  In your Calendar Table, write calculated column formulas to extract Year and YearMonth.  To your visual, drag Year and YearMonth from the Calendar Table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@sraj , the display you want needs month and year separately so that it can combine.

 

How do you want to diff between year and month?

 

You need to have a year month table, I sometimes create date from the year month and use date table. But you need separate table 

 

Add month rank as column in table on year month

 

Month Rank = RANKX(all('Date'),'Date'[Month Start date],,ASC,Dense)
Month Rank = RANKX(all('Date'),'Date'[Year Month],,ASC,Dense)

 

 

This Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))

Last Year same month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month]=max('Period'[Month]) && 'Date'[Year]=max('Date'[Year])-1))

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.