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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jrsommer
Frequent Visitor

Create Measure that calculates sum 1 of 2 ways based on client

Hello all!

I feel like this should be 'straightforward' but perhaps I'm just new enough to be struggling with this. 

I need to create a measure that SUMS my 'Cost' field. However the needed calculation will vary for 1 particular client. Hopefully this helps explain what I mean/need:


IF ([ClientName] = "A"

SUM('table'[Cost]),'table'[Type] ="Cloud",'table'[ClientName]="A") + 
SUM('table'[Cost]),'table'[Type] ="Cloud",'table'[ClientName]="B")*.35


ELSE


CALCULATE(SUM('table'[Cost]),'table'[Type] ="Cloud")

 I dont expect that syntax to be at all correct, I was just trying to type it out so the different parts are clear. 

 FOR WHAT ITS WORTH: In Excel, I calculated this by the following: (This was only entered in the client specifc cell)
=SUMIFS(R:R,A:A,"A",B:B,"Cloud")+(SUMIFS(R:R,A:A,"B",B:B,"Cloud",C:C,"Engineering",D:D,"Azure")*0.35)

 

Thank you for your help!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@jrsommer , Test as

IF (max([NombreDeUsuario)] - "A"
calculate(SUM('table'[Cost]),filter('table'[Type] '"Cloud",'table'[ClientName]-"A")) +
calculate(SUM('table'[Cost]),filter(all('table'[ClientName]) ,'table'[Type] '"Cloud",'table'[ClientName]'"B"))*.35
,CALCULATE(SUM('table'[Cost]),'table'[Type] ?" Cloud"))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@jrsommer , Test as

IF (max([NombreDeUsuario)] - "A"
calculate(SUM('table'[Cost]),filter('table'[Type] '"Cloud",'table'[ClientName]-"A")) +
calculate(SUM('table'[Cost]),filter(all('table'[ClientName]) ,'table'[Type] '"Cloud",'table'[ClientName]'"B"))*.35
,CALCULATE(SUM('table'[Cost]),'table'[Type] ?" Cloud"))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

i think this is what i'm looking for. Need to do some data clean up and then i'll test it out.
FYI: Syntax had to be corrected when i typed the formula out, so hopefully i got it all correct.

Thank you!

AllisonKennedy
Super User
Super User

Try as a new MEASURE:

 

Total Cost = 

 

IF (SELECTEDVALUE([ClientName])= "A"
SUMX(FILTER(ALL('table','table'[Type] ="Cloud" && table[ClientName]="A"), table'[Cost])  + 
SUMX(FILTER(ALL('table'),'table'[Type] ="Cloud" && table[ClientName]="B"), table'[Cost])*.35

CALCULATE(SUM('table'[Cost]),'table'[Type] ="Cloud")

)

 

NOTE: I haven't changed your CALCULATE statement, but you could use a SUMX here too if you want, and wasn't sure if that should be for only selected client.

 

Another note, how is this going to be used? It will only work if only 1 client is selected in context (so client name must be in the visual or must have a filter for 1 client only).

 

You could use SUMX to change that and improve if you want.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thank you so much for you assistance but i wil not be filtering/selecting a client on this page

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.