Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreShape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.
I'm trying to do simple subtraction of two columns. I'm creating a pay register. I have a column with earnings, a column with deductions and want to subtract deductions from earnings to create a new column, net pay for each employee.
Earnings and deductions come from separate tables. When I try to subtract these, it always aggregates the amounts, rather than giving me just the amount for each.
How do I successfully subtract?
Solved! Go to Solution.
Hi, @adraus
You can try the following methods.
Measure =
SELECTEDVALUE(_GroupEarnings[_EarnAmount])-SELECTEDVALUE(_GroupDeductions[_DedAmount])
Measure 2 =
SUM(_GroupEarnings[_EarnAmount])-SUM(_GroupDeductions[_DedAmount])
Both of these measures give the result of subtracting two columns.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more.
Hi, @adraus
You can try the following methods.
Measure =
SELECTEDVALUE(_GroupEarnings[_EarnAmount])-SELECTEDVALUE(_GroupDeductions[_DedAmount])
Measure 2 =
SUM(_GroupEarnings[_EarnAmount])-SUM(_GroupDeductions[_DedAmount])
Both of these measures give the result of subtracting two columns.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more.
If the only connections are the year and payperiod (and presuming they will have same payperiod in both tables moving forward) you could try TREATAS:
Total =
VAR earnings =
MAX ( GroupEarnings[Earnings] )
VAR deductions =
MAX ( GroupDeductions[_DedAmount] )
RETURN
CALCULATE (
earnings - deductions,
TREATAS (
SELECTCOLUMNS (
GroupEarnings,
"Year", GroupEarnings[Year],
"Payperiod", GroupEarnings[Payperiod]
),
GroupDeductions[Year],
GroupEarnings[Payperiod]
)
)
Hi @adraus
Try this.
Let me know if you have any questions.
Total =
var _earn = MAX(Earnings[Earnings])
var _ded = MAX(Deductions[Deductions])
return _earn- _ded
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
I'm not having success. The new column is showing the same invalid value all the way down.
Perhaps I missed something in the command?
Hi @adraus ,
In order to have data from two different tables they have to be linked in some fashion.
Here is one way.
Please tell me, is this for a short term project or something else. Can you share your pbix with me?
If you would share your pbix, or dummy up some values in Excel both for current and expected data. Please copy and paste them into your post, rather than doing a picture, we may be able to help you.
Please read this post to get your question answered more quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Nathaniel
Proud to be a Super User!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
User | Count |
---|---|
21 | |
20 | |
20 | |
13 | |
13 |
User | Count |
---|---|
41 | |
28 | |
25 | |
23 | |
21 |