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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

How can I create a bar chart that shows the difference between two values according to their dates

Hello! I'm new to PowerBI and can't figure this one out.

I have an Excel datasheet with 4 main columns, the first has the product name, the second has the some parameters related to the products, the third has the value of thoses parameters, and the last has the year when that parameter was measured.

I need to create a visual that shows how muc the parameters have changed according to the filtered product and time (eg: if I choose to filter 2022 and 2021 and product X, the visual would show the difference between the values of the parameters measured on those two years for that product).

I was trying to do it by creating a bar chart and the two filters (for year and product), but can only find how to get the sum or take the average of the values. Is there a way to get the difference or subtraction?

 

Here's how I tryed and the Excel sheet:

AverageAverageSumSumDatasheetDatasheet

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Anonymous ,

Give your data screenshot, I would use a formula similar to this:

Diff = 
VAR __PREV =
    CALCULATE (
        SUM ( 'Table'[Measured] ),
        ALL ( 'Table'[Year] ),
        'Table'[Year]
            = MAX ( 'Table'[Year] ) - 1
    )
RETURN
    SUM ( 'Table'[Measured] ) - __PREV


You can see in the image below that measure above returns the difference between two years (Product A for 2022-- 3.48-.047 = 3.01)

danextian_1-1653008095182.png

 

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @Anonymous ,

Give your data screenshot, I would use a formula similar to this:

Diff = 
VAR __PREV =
    CALCULATE (
        SUM ( 'Table'[Measured] ),
        ALL ( 'Table'[Year] ),
        'Table'[Year]
            = MAX ( 'Table'[Year] ) - 1
    )
RETURN
    SUM ( 'Table'[Measured] ) - __PREV


You can see in the image below that measure above returns the difference between two years (Product A for 2022-- 3.48-.047 = 3.01)

danextian_1-1653008095182.png

 

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Thank you so much! It worked even better than what I was initially trying to do 😁

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.