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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure difference value between years - how to calculate?

I'm looking to use my date/year slicer to show the difference in values based on the following:

 

Item1 2014 $100

Item1 2015 $105 $5

Item1 2016 $110 $10

 

I'd like to have a new column at the end in my Matrix to show the increase/difference from 2014 to 2016, or whatever item/year I have selected from the slicer.  Can this be done easily, or is there more context reuquired for what I'm after?

 

Thank you!

5 REPLIES 5
v-ljerr-msft
Employee
Employee

Hi @Anonymous,

 

I assume you have a table called "Table1" like below.

 

t1.PNG

 

Then you should be able to use the formula below to create a measure to calculate the increase/difference, then show the measure on the report.Smiley Happy

Difference =
VAR minYearSelected =
    CALCULATE ( MIN ( Table1[Year] ), ALLSELECTED ( Table1 ) )
RETURN
    SUMX (
        Table1,
        Table1[Value]
            - CALCULATE (
                SUM ( Table1[Value] ),
                FILTER ( ALL ( Table1 ), Table1[Year] = minYearSelected )
            )
    )

r2.PNG

 

Regards

Anonymous
Not applicable

If it matters, the field "value" is a measure from a SUM of other data.  So, this is what I have and Power BI says "Too many arguments were passed to the SUM function. The maximum argument count for the function is 1"

 

Difference = VAR minYearSelected = CALCULATE(min ('Table1'[Year]), ALLSELECTED( 'Table1' ) ) RETURN SUMX ('Table1',[Value] - CALCULATE (SUM (([Value]), FILTER( ALL('Table1'),'Table1'[Year] = minYearSelected ) ) ))

 

Is the measure throwing it off or am I missing something else?

 

Thank you!

Hi @Anonymous,

 

Please try the formula below to see if it works in your scenario.Smiley Happy

Difference =
VAR minYearSelected =
    CALCULATE ( MIN ( 'Table1'[Year] ), ALLSELECTED ( 'Table1' ) )
RETURN
    SUMX (
        'Table1',
        [Value]
            - CALCULATE (
                [Value],
                FILTER ( ALL ( 'Table1' ), 'Table1'[Year] = minYearSelected )
            )
    )

 

Regards

Anonymous
Not applicable

That formula's syntax works, but it's not giving the correct value.  

 

Since the 'value' measure is really another measure divided by a different value, I could be making it more confusing.  What you provided seems to be adding data and not sure from where.

 

Let me play around with what you've given me so far & see if I can make it work.  Thanks!

Hi @Anonymous,

 

Have you solved this issue? If you still have any question on it, feel free to post it here. 

 

If the issue got resolved, could post the solution here to help others who may also have the similar issue easily find the answer and close this thread? Smiley Happy

 

Regards

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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