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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

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