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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

Subtraction and Percentage difference

Hi everyone.

 I have "net shipmant" column from 2019 and "net shipmnat" from 2018.

"variance order" is my 2019 and 2018 filter.

InkedCapture_LI.jpg

 

now I want to create 2 columns wich will be calculate

1. Net variance $   (2019-2018)

2. Net variance %

 

For the first case the results are :

 $152.50 - $499.00 =  ($346.50)

 $0 - $118.48 = ($118.48)

 $1,655.88 - $5,466.85 = ($3,810.97) 

      ......

my sql code: =Sum(iif(Fields!VarianceOrder.Value=1,val(Fields!NetShipments.value),0))
-
Sum(iif(Fields!VarianceOrder.Value=2,val(Fields!NetShipments.value),0)) 

 

 

 

 

For the second case the results are:

-69.44%

-100.00%

-69.71%

.....

my sql code: =(Sum(iif(Fields!VarianceOrder.Value=1,val(Fields!NetShipments.value),0))
-
Sum(iif(Fields!VarianceOrder.Value=2,val(Fields!NetShipments.value),0)))
/
Sum(iif(Fields!VarianceOrder.Value=2,val(Fields!NetShipments.value),0))

 

 

Please help me solve this problem 🙂

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

You may create two measures to get the value.

Percentage =
VAR _2019 =
    CALCULATE (
        SUM ( Table1[NetShipments] ),
        FILTER ( Table1, Table1[Year] = 2019 )
    )
VAR _2018 =
    CALCULATE (
        SUM ( Table1[NetShipments] ),
        FILTER ( Table1, Table1[Year] = 2018 )
    )
RETURN
    IF (
        ISFILTERED ( Table1[Year] ),
        SUM ( Table1[NetShipments] ),
        FORMAT ( DIVIDE ( _2019 - _2018, _2018 ), "Percent" )
    )

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous 

You may create a measure like below.Attached sample file for your reference.

Measure =
VAR _2019 =
    CALCULATE (
        SUM ( Table1[NetShipments] ),
        FILTER ( Table1, Table1[Year] = 2019 )
    )
VAR _2018 =
    CALCULATE (
        SUM ( Table1[NetShipments] ),
        FILTER ( Table1, Table1[Year] = 2018 )
    )
RETURN
    IF (
        ISFILTERED ( Table1[Year] ),
        SUM ( Table1[NetShipments] ),
        IF (
            SELECTEDVALUE ( Table2[Order] ) = 1,
            _2019 - _2018,
            IF (
                SELECTEDVALUE ( Table2[Order] ) = 2,
                DIVIDE ( _2019 - _2018, _2018 ),
                SUM ( Table1[NetShipments] )
            )
        )
    )

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

it's not work 😕 ... are there any other idea?

Anonymous
Not applicable

@v-cherch-msft , I need two columns one is substraction another one is percentage. In your example I understand that with checkbox i can select wiche one i want to  see, but checkbox in my report is just 2018 and 2019 years columns

Hi @Anonymous 

You may create two measures to get the value.

Percentage =
VAR _2019 =
    CALCULATE (
        SUM ( Table1[NetShipments] ),
        FILTER ( Table1, Table1[Year] = 2019 )
    )
VAR _2018 =
    CALCULATE (
        SUM ( Table1[NetShipments] ),
        FILTER ( Table1, Table1[Year] = 2018 )
    )
RETURN
    IF (
        ISFILTERED ( Table1[Year] ),
        SUM ( Table1[NetShipments] ),
        FORMAT ( DIVIDE ( _2019 - _2018, _2018 ), "Percent" )
    )

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.