Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi all,
I have a simple question that I only encounter now: Why can't I subtract a measure to an imported column?
Below example that Actual sales (a dax measure) and Target (imported number) and desired result of Var (Actual Sales - Target)
I normally have Measure - Measure and it's simple, but what shall I do in this situation? Thank you.
Name | Target | Actual sales | Var |
A | 100% | 100% | 0% |
B | 100% | 80% | -20% |
C | 100% | 70% | -30% |
Solved! Go to Solution.
if I correctly understand your situation, you need to substract measure from the current value:
measure =
VAR currentTarget = SELECTEDVALUE ( T[Target] )
RETURN
[measureName] - currentTarget
If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
Hi @milkynight
I'm glad you found the solution.
You can not use a column name in the measure to find the value; you must wrap the column in an aggregation function like MIN, MAX, SUM, AVERAGE, etc.
In your case, because you used the Name column, if you use Min or Max, it will return the value corresponding to that row.
https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Hi @milkynight
Try this:
Var=
Var _AS = [Actual sales]
Var _Tar = max(table(Target))
return
_AS-_Tar
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
@VahidDM thanks, I guess your DAX can be shortened to: Var = [Actual Sales] - max(table [Target])?
Both long and short version works, but I'm curious why we use max for Target?
Hi @milkynight
I'm glad you found the solution.
You can not use a column name in the measure to find the value; you must wrap the column in an aggregation function like MIN, MAX, SUM, AVERAGE, etc.
In your case, because you used the Name column, if you use Min or Max, it will return the value corresponding to that row.
https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
if I correctly understand your situation, you need to substract measure from the current value:
measure =
VAR currentTarget = SELECTEDVALUE ( T[Target] )
RETURN
[measureName] - currentTarget
If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
Thanks you, this solution is good for me
@ERD thanks so much, it works nicely.
Just curious, does the first clause mean to convert the imported value to Measure? I tried with VALUES originally and it didn't work
VAR currentTarget = SELECTEDVALUE ( T[Target] )
@milkynight , SELECTEDVALUE function is used in a measure to return a value when the context for ColumnName has been filtered down to one distinct value. I'd say read and use column value in further calculations instead of 'convert'.
You can read about the function here: https://dax.guide/selectedvalue/
Also you could use MAX function instead. In this particular case it will do the same.
If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |