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
Vanchief
Regular Visitor

Subtract and add values to a specific row

Hi everyone,

I'm struggling with a DAX measure and could really use some help.

Here's what I currently have:

x_CCX_Company_controlsumexlogs =
VAR Effectivecostexlogs =
CALCULATE(
SUM('FOCUS'[EffectiveCost]) -
[x_CCX_Company_Loganalytics_Shared] -
[x_CCX_company_Loganalytics_app_company]
)
RETURN
Effectivecostexlogs

This measure works as expected—it calculates the total EffectiveCost minus two other values.

What I want to do now: I need to add back [x_CCX_company_Loganalytics_app_company] only for one specific row (let's say for "Company A") in another table called x_costcenter.

All other rows should remain unaffected. The goal is to adjust the result only for that one company, without changing the overall logic for the rest.

Does this make sense? Is there a way to conditionally add that value back just for "Company A"?

Thanks in advance!





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

Hi Vanchief,

Thank you for your follow-up.

Please find attached the screenshot and the revised sample PBIX file for your reference. We have corrected the logic so that the amount of 2000 is now distributed proportionately across companies A, B, and C. The total increase matches the value in cell C2, which is 2000.

vpnarojumsft_0-1752836912886.png

We trust that the information provided will help resolve the issue. Should you have any further queries, please feel free to contact the Microsoft Fabric community.

Thank you.

View solution in original post

16 REPLIES 16
Khushidesai0109
Super User
Super User

Hii @Vanchief 
Can you please try this 
x_CCX_Company_controlsumexlogs =
VAR BaseEffectiveCost =
SUM('FOCUS'[EffectiveCost])
VAR LogAnalyticsShared =
[x_CCX_Company_Loganalytics_Shared]
VAR LogAnalyticsAppCompany =
[x_CCX_company_Loganalytics_app_company]
VAR CompanyName =
SELECTEDVALUE(x_costcenter[CompanyName]) -- Adjust column name if needed
VAR AdjustedEffectiveCost =
BaseEffectiveCost - LogAnalyticsShared - LogAnalyticsAppCompany +
IF(CompanyName = "Company A", LogAnalyticsAppCompany, 0)
RETURN
AdjustedEffectiveCost


If this helps, I would appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!
Proud to be Super User!!


v-pnaroju-msft
Community Support
Community Support

Hi Vanchief,

Thank you for your follow-up.

Please find attached the screenshot and the revised sample PBIX file for your reference. We have corrected the logic so that the amount of 2000 is now distributed proportionately across companies A, B, and C. The total increase matches the value in cell C2, which is 2000.

vpnarojumsft_0-1752836912886.png

We trust that the information provided will help resolve the issue. Should you have any further queries, please feel free to contact the Microsoft Fabric community.

Thank you.

This works!, I just had to modify the filter so it matches New_Costcenter -> Otherwise it adds the shared cost accumulating for every month. 🙂

v-pnaroju-msft
Community Support
Community Support

Hi Vanchief,

Based on my understanding of the issue, please find attached a screenshot and a sample PBIX file that may assist in resolving the matter:

vpnarojumsft_0-1752778053186.png

We hope the information provided helps to resolve the issue.
Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.

Thank you.

It seems to calculate to every row, which is not the desired behaviour.
New_effectivecost is effectivecost minus C2 which is 2000
So I want to distribute these 2000 across company A,B,C -> However the sheet you've provided I can see that Final_Adjusted_Cost increases the companies respectly 

Company A: was 1800 -> to now 4182,98 increases 2382,98
Company B: was 3600 -> to now 4365,96 increases 765,96

Company C: was 4000 -> to now 4851,06 increases 851,06

But the total increases should only match C2 which is 2000?

v-pnaroju-msft
Community Support
Community Support

Hi Vanchief,

Thank you for the update.

We kindly request you to provide sample data that clearly demonstrates your issue or query in a structured format (not as an image) to help us understand and resolve the matter. Please ensure that the data is relevant, free from any sensitive information, and directly related to the issue. Additionally, please share the expected outcome based on the given example.

Thank you.

I have sample data in a powerbi, however I don't seem to be able to upload the pbix file here.

The coloumn "New_Effectivecost" is a calculated column, based on the following:
First I've created a measure that calculate the sum for resourceID C2 which is the resourceID that should be distribuated to all companies based on their total contribution in effectivecost.

New_Effectivecost = FOCUS[Effectivecost] - [SharedCost]

 

So the table looks like this:

 

CostcenterChargeperiodstartResourceIDEffectivecostNew_Effectivecost
Company A19-06-2025 02:00:00A1300300
Company A19-06-2025 02:00:00A2500500
Company A19-06-2025 02:00:00A310001000
Company B18-06-2025 02:00:00B1600600
Company B18-06-2025 02:00:00B210001000
Company B18-06-2025 02:00:00B320002000
Company C17-06-2025 02:00:00C110001000
Company C17-06-2025 02:00:00C220000
Company C17-06-2025 02:00:00C330003000

 

What I now want to recieve in my visual is a table containing:
Costcenter as rows
Chargeperiodstart(month) as columns
New_Effectivecost (sum) as values

That easy enough, however we're missing the sharedcost, so how do I readd that to all companies based on their contribution towards the total effectivecost.

*Edit* 
I managed to get a anyone link to the temp file
iCloud Drive - Apple iCloud

Hi,

It will help if you share an MS Excel file with your formulas written there.  This will enable me to understand your logic and translate those formulas in the DAX language.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Here it comes: 
iCloud Drive - Apple iCloud

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1752899799581.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-pnaroju-msft
Community Support
Community Support

Hi Vanchief,

We would like to follow up and see whether the details we shared have resolved your problem.
If you need any more assistance, please feel free to connect with the Microsoft Fabric community.

Thank you.

I’ve had some time to review the setup, and I don’t think my current tables can support the suggested result as-is.

I’m working with the FOCUS table, which contains a lot of data, including the key columns I’m using:
Costcenter, EffectiveCost, and ResourceID, among others.

Vanchief_0-1752578286854.png

 

I’ve created a new column that completely removes the shared cost. I also reallocated the cost from Company B to Company A and added a percentage measure to track each company’s cost contribution.

Now, I’d like to reintroduce the shared Log Analytics cost. However, that cost is already present in the FOCUS table, and when I try to add it back, it only appears under an empty Costcenter.

Sorry for my late reponse, I tried to create relations between the tables. But realized that I have "Duplicated" values in x_costcenter, containing (blank). So I need to modify these blank values before I am able to create relations.

v-pnaroju-msft
Community Support
Community Support

Thankyou, @bhanu_gautam, for your response.

Hi Vanchief,

We appreciate your question on the Microsoft Fabric Community Forum.

Based on my understanding of the issue, we tested the scenario with a sample dataset and were able to get the expected result.

Here are the main steps we followed:

  1. Created three sample tables named FOCUS, x_costcenter, and LogAnalytics.
  2. Set active relationships between FOCUS[Company] and x_costcenter[Company], and also between FOCUS[Company] and LogAnalytics[Company].
  3. Made two helper measures to get Loganalytics_Shared and Loganalytics_App_Company using the MAX() function from LogAnalytics.
  4. Wrote a conditional DAX measure using SELECTEDVALUE(FOCUS[Company]) to add App_Company only for Company A.
  5. Added a table visual with FOCUS[Company] and the final DAX measure to show the updated values.

This logic adds values only for Company A and keeps the original logic for the other companies.

Please find attached the screenshot and sample PBIX file for your reference:

vpnarojumsft_0-1752133816992.png

We hope this information helps you solve the problem.
If you have any more questions, please feel free to contact the Microsoft Fabric community.

Thank you.

bhanu_gautam
Super User
Super User

@Vanchief , Try using

 

DAX
x_CCX_Company_controlsumexlogs =
VAR Effectivecostexlogs =
CALCULATE(
SUM('FOCUS'[EffectiveCost]) -
[x_CCX_Company_Loganalytics_Shared] -
[x_CCX_company_Loganalytics_app_company]
)
VAR AdjustedCost =
IF(
SELECTEDVALUE(x_costcenter[Company]) = "Company A",
Effectivecostexlogs + [x_CCX_company_Loganalytics_app_company],
Effectivecostexlogs
)
RETURN
AdjustedCost




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Same issue -> nothing happens to my row company A

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.