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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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