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

Difference of dimensions between measures

Capture.PNG

Hi All, 

 

I have calculated two measures gross margin and profit margin as above. 

 

I have a dimension in my data set "actual" and "plan". I am able to place the actual and plan in the column but i am unsure of how to put a variance (actual - plan) into the column beside "plan". Is there a way to do this? 

 

Thanks for your help

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

You need to create 3 measures as below:

 

Gross Margin = CALCULATE(MIN('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
Profit = CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
result = 
VAR actual =
    CALCULATE (
        SWITCH (
            SELECTEDVALUE ( 'Table (2)'[row] ),
            "Gross Margin", 'Table'[Gross Margin],
            "Profit", 'Table'[Profit]
        ),
        'Table'[Category] = "actual"
    )
VAR plan =
    CALCULATE (
        SWITCH (
            SELECTEDVALUE ( 'Table (2)'[row] ),
            "Gross Margin", 'Table'[Gross Margin],
            "Profit", 'Table'[Profit]
        ),
        'Table'[Category] = "plan"
    )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Column'[Column] ),
        "actual", actual,
        "plan", plan,
        plan - actual
    )

and another 2 tables showed as below:

Table    ColumnTable ColumnTable       Table(2)Table Table(2)

Finally you will see:

 

1123.png

 

For the related .pbix file,pls click here.

 

Best Regards,

Kelly

 

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

How you create the current view.  Can you share calculations.

Anonymous
Not applicable

Capture.PNG

 

 

So gross profit is calculated as profit/revenue and gross margin is cost/revenue. The version is a column in my dataset containing "actual" and "plan".  

Hi @Anonymous ,

 

You need to create 3 measures as below:

 

Gross Margin = CALCULATE(MIN('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
Profit = CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
result = 
VAR actual =
    CALCULATE (
        SWITCH (
            SELECTEDVALUE ( 'Table (2)'[row] ),
            "Gross Margin", 'Table'[Gross Margin],
            "Profit", 'Table'[Profit]
        ),
        'Table'[Category] = "actual"
    )
VAR plan =
    CALCULATE (
        SWITCH (
            SELECTEDVALUE ( 'Table (2)'[row] ),
            "Gross Margin", 'Table'[Gross Margin],
            "Profit", 'Table'[Profit]
        ),
        'Table'[Category] = "plan"
    )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Column'[Column] ),
        "actual", actual,
        "plan", plan,
        plan - actual
    )

and another 2 tables showed as below:

Table    ColumnTable ColumnTable       Table(2)Table Table(2)

Finally you will see:

 

1123.png

 

For the related .pbix file,pls click here.

 

Best Regards,

Kelly

 

This one is tricky. Create a diff column. for these you need to use actual and plan as filter. 

The using summarize and union , you have to merge the current result with new columns.

 

 

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can create a measure Variance = [actual] - [plan]

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

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.