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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
KMGC
Regular Visitor

Request Assistance:DAX Formula to Calculate Surplus based on differing contract minimums by location

Hi all,

 

Been looking and couldn't find anything that would help me with this one. I have different locations with different contract minimums. I have a dax measure for total sales and then I want to calculate the revenue surplus based on the contract minimum for a location. Essentially subtracting the location-specific contract minimum amount from the total sales amount for that location. 

 

I have looked in a bunch of places to recreate a 'nested if' and I'm stumped. Here's the current table:

 

KMGC_0-1710339780306.png

The 'Revenue Surplus' measure being used right now just takes the total sales measure and subtracts $1,000. I need to be able to change that amount based on the location. All of the data is in one table and the only measures from that table are 'Total Sales' and 'Revenue Surplus.'

 

'Total Sales'= SUM(Sales)

'Revenue Surplus'= [Total Sales]-1000 (this is the one I need to change)

 

Any help would be appreciated. Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @KMGC 

 

Please try this:

First of all, I create a set of sample:

vzhengdxumsft_0-1710382757474.png

And you need to create a new table to store contract minimums:

vzhengdxumsft_1-1710383071515.png

 

Then create a 1:* relationship between the two tables:

vzhengdxumsft_2-1710383111419.png

Then add 2 measure:

TOTAL = SUM('Table'[Total Sales])
Revenus =
[TOTAL]
    - CALCULATE (
        MAX ( 'Table (2)'[contract minimums] ),
        'Table (2)'[Location] = SELECTEDVALUE ( 'Table'[Location] )
    )

The result is as follow:

vzhengdxumsft_3-1710383198611.png

 

Best Regards

Zhengdong Xu
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

2 REPLIES 2
KMGC
Regular Visitor

Works perfectly. Thanks!

Anonymous
Not applicable

Hi @KMGC 

 

Please try this:

First of all, I create a set of sample:

vzhengdxumsft_0-1710382757474.png

And you need to create a new table to store contract minimums:

vzhengdxumsft_1-1710383071515.png

 

Then create a 1:* relationship between the two tables:

vzhengdxumsft_2-1710383111419.png

Then add 2 measure:

TOTAL = SUM('Table'[Total Sales])
Revenus =
[TOTAL]
    - CALCULATE (
        MAX ( 'Table (2)'[contract minimums] ),
        'Table (2)'[Location] = SELECTEDVALUE ( 'Table'[Location] )
    )

The result is as follow:

vzhengdxumsft_3-1710383198611.png

 

Best Regards

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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