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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register 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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.