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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Calculate difference in measure between category vs grand total change over time (.pbix attached)

I have a measure that calculates the % of two other columns (it is Freight as a % of sales). I want to calculate how this has changed over time and difference of the categories versus the grand total from a prior period. I'm unclear how to do this.

 

I have attached an example data set as well as a picture below of what I'm trying to do.

 

Example

Category A is 1.2% in 2020

The Grand Total in 2019 was 0.38%

The difference between Category A in 2020 vs. the Grand Total is 0.35% - 1.20% = -0.85%.

 

How do I calculate this difference? 

 

Example data in PowerBI: https://1drv.ms/u/s!AvCirXUmRp-JhbY86LW-Vr-skR6XPw?e=AmqJYb

 

 

example change.png

 

 

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Please try this expression to get your desired result.

 

NewMeasure =
VAR thisyear =
    MIN ( DateTable[Year] )
VAR freightpctsalesminus = [Freight % of Sales minus % Change Difference]
VAR PYtotal =
    CALCULATE (
        [Freight % of Sales],
        ALL ( 'Table'[Category] ),
        ALL ( DateTable ),
        VALUES ( DateTable[Quarter] ),
        DateTable[Year] = thisyear - 1
    )
RETURN
    PYtotal - freightpctsalesminus

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer to the measure below:

 

Measure =
VAR lastyear =
    CALCULATE (
        [Freight % of Sales],
        ALL ( 'Table'[Category] ),
        SAMEPERIODLASTYEAR ( DateTable[Date] )
    )
RETURN
    lastyear - [Freight % of Sales minus % Change Difference]

 

 

Capture.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

mahoneypat
Employee
Employee

Please try this expression to get your desired result.

 

NewMeasure =
VAR thisyear =
    MIN ( DateTable[Year] )
VAR freightpctsalesminus = [Freight % of Sales minus % Change Difference]
VAR PYtotal =
    CALCULATE (
        [Freight % of Sales],
        ALL ( 'Table'[Category] ),
        ALL ( DateTable ),
        VALUES ( DateTable[Quarter] ),
        DateTable[Year] = thisyear - 1
    )
RETURN
    PYtotal - freightpctsalesminus

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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