Forum Discussion
DAX IF Statement to compare % difference between two values and return TEXT
- 3 years ago
Hi MiloPowerBI ,
According to your description, here's my solution.
Create a calculated column in the Plan table.
Perform to plan = IF ( ABS ( DIVIDE ( RELATED ( 'Actual'[Actual] ) - 'Plan'[Plan], 'Plan'[Plan] ) ) <= 0.1, "Hit", "Miss" )Result:
If you want a visual to show the number of the misses and hits, put the Perform to plan in a column chart both in X-axis and Y-axis, and select count in the Y-axis, get the result:
I attach my sample below for your reference.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best regards,
Community Support Team_yanjiang
MiloPowerBI , If Plan and actual need to be a measure. you need a new measure like
if([Actual]<[Plan], "Miss", "Hit")
Now if you hit hand miss in the slicer or on axis, You need to do dynamic segmentation with independent table
refer this video for process
Customer Retention with Dynamic Segmentation, New/Lost/Retain Customer Count: https://youtu.be/EyL7KMw877Q
- MiloPowerBI3 years agoFrequent Visitor
Hello amitchandak,
Thank you for your response, and that video did help me understand a bit better.
However, the measure you proposed [if([Actual]<[Plan], "Miss", "Hit")] doesnt quite fit the bill. This will only return a Miss if the Actual is less than the Plan and a Hit if the Actual is more than the Plan. I'm looking to do something like if the Actual is within 10% of the Plan - higher OR lower - its a Hit.
If the Plan is 100 and the Actual is 98, I would want this to return as a Hit, the measure you proposed would return a Miss for this.
Any further advice?
Thank you.