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

Variance Calculation by Condition

Hi 

I'm trying to create the variance between actual vs budget.  I have tables one for actual and another for budget, and they both have a relationship to "Date" and "Account List" tables. 

 

I want to show the variance between actual and budget table with condition that :

If it's revenue accounts, it will do  Actual  less Budget, 

If it's expense accounts, it will do Budget less Actual. 

 

I tried to do a measure, but the value did not come out correctly.

 

Var $ Test =
SUMX(Actual,
              IF(RELATED('Account List'[Type])="Income",
                 [Actual $]-[Budget $],
                 [Budget $]-[Actual $]
      )
)

 

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We create a sample like this,

 

Va1.jpg

 

Then we can create a measure to meet your requirement.

 

Var $ Test = 
IF(
    MAX('Account List'[Type]) = "income",
    SUM('actual table'[Actual]) - SUM('Budget Table'[Budget]),
    SUM('Budget Table'[Budget]) - SUM('actual table'[Actual]))

 

The result like this,

 

va2.jpg

 

If it doesn’t meet your requirement, could you please provide a mockup sample based on fake data?

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

3 REPLIES 3
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We create a sample like this,

 

Va1.jpg

 

Then we can create a measure to meet your requirement.

 

Var $ Test = 
IF(
    MAX('Account List'[Type]) = "income",
    SUM('actual table'[Actual]) - SUM('Budget Table'[Budget]),
    SUM('Budget Table'[Budget]) - SUM('actual table'[Actual]))

 

The result like this,

 

va2.jpg

 

If it doesn’t meet your requirement, could you please provide a mockup sample based on fake data?

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

amitchandak
Super User
Super User

@Anonymous , assuming actual and budget are measures 

 

Var $ Test =
SUMX('Account List',
IF(('Account List'[Type])="Income",
[Actual $]-[Budget $],
[Budget $]-[Actual $]
)
)

DataInsights
Super User
Super User

Hi @Anonymous, create the three measures below:

 

Actual $ = SUM ( Actual[Amount] )

Budget $ = SUM ( Budget[Amount] )

Var $ =
VAR vAccountType =
    MAX ( AccountList[AccountType] )
VAR Result =
    SWITCH (
        vAccountType,
        "Revenue", [Actual $] - [Budget $],
        "Expense", [Budget $] - [Actual $]
    )
RETURN
    Result

 

In a matrix visual, add AccountList[Account] as rows, and the three measures above as values.





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

Proud to be a Super User!




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.