Forum Discussion
Categorise Plus or Minus %
- 2 years ago
Hi,
You can solve this with segmentation. I have solved a similar problem in the attached file.
Hope this helps.
Hi, Batman_powerbi
Thanks for bhanu_gautam positive reply. You can try following dax to achieve your need.
DAX:
Plus/Minus $ Range by Project Column =
VAR __BASELINE_VALUE =
CALCULATE (
SUM ( 'Table'[Estimate $] ),
FILTER ( 'Table', 'Table'[Project] = EARLIER ( 'Table'[Project] ) )
)
VAR __VALUE_TO_COMPARE =
CALCULATE (
SUM ( 'Table'[Actual $] ),
FILTER ( 'Table', 'Table'[Project] = EARLIER ( 'Table'[Project] ) )
)
VAR _difference =
IF (
NOT ISBLANK ( __VALUE_TO_COMPARE ),
DIVIDE ( __VALUE_TO_COMPARE - __BASELINE_VALUE, __BASELINE_VALUE )
)
VAR _plusMinus =
SWITCH (
HASONEVALUE ( 'Table'[Estimate $] ),
_difference <= -0.3
&& _difference > -0.4, "+/- 30%",
_difference <= -0.2
&& _difference > -0.3, "+/- 20%",
_difference <= -0.1
&& _difference > -0.2, "+/- 10%",
_difference <= 0.05
&& _difference > -0.1, "+/- 5%",
_difference >= 0.05
&& _difference < 0.1, "+/- 5%",
_difference >= 0.1
&& _difference < 0.2, "+/- 10%",
_difference >= 0.2
&& _difference < 0.3, "+/- 20%",
_difference >= 0.3
&& _difference < 0.4, "+/- 30%",
"+/- 40% or more"
)
RETURN
_plusMinus
Count =
COUNTROWS('Table')
% Overall =
VAR _allCounts = CALCULATE(COUNTROWS('Table'),ALL('Table'))
VAR _result = DIVIDE([Count],_allCounts)
RETURN
_result
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
- Batman_powerbi2 years agoFrequent Visitor
Anonymous
unfortunately the sample table and output is incorrect as it is evaluating every row in the tablepossibly i wasnt clear in my inital post
i wish to calculate and evaluate the Plus/Minus category against Project and Function separately
so in your sample, if i were to calculate this, there should be only a count of 3 total allocated to the %
if i were to do it by Role, i would have a count of 4 total due to the 4 separate roles.