Forum Discussion
Conditional Index
- 4 years ago
Hi,
Please check the below picture and the attached pbix file.
Actual CC = VAR _startdate = MIN ( Data[Date] ) VAR _startnumber = MAX ( Data[Planned] ) VAR _conditiontable = ADDCOLUMNS ( Data, "@condition", IF ( Data[State] = "Closed", -1 ) ) VAR _cumulatecondition = SUMX ( FILTER ( _conditiontable, Data[Date] <= EARLIER ( Data[Date] ) ), [@condition] ) RETURN _startnumber + _cumulatecondition - 4 years ago
Anonymous this is another alternative, but Jihwan_Kim solution is also great.
Actual CC = VAR _startnumber = MAX ( Data[Planned] ) VAR _minus_count = COUNTROWS( FILTER( Data, Data[Planned] >= EARLIER(Data[Planned]) && Data[State] = "Closed") ) VAR _result = _startnumber - _minus_count RETURN _result
Anonymous this is another alternative, but Jihwan_Kim solution is also great.
Actual CC =
VAR _startnumber =
MAX ( Data[Planned] )
VAR _minus_count =
COUNTROWS(
FILTER(
Data,
Data[Planned] >= EARLIER(Data[Planned]) && Data[State] = "Closed")
)
VAR _result = _startnumber - _minus_count
RETURN
_result
- Anonymous4 years agoNot applicable
Hello SpartaBI,
thanks a lot for your feedback. It works frine on my end. It looks such a simple code but I would never have been able to write it with my limited skills in DAX language. One question. When I would like to add more than one option than the state 'Closed', e.g. 'Cancelled' and 'Done' how can I add these two additional states to the script?
Thanks
Olaf
- SpartaBI4 years agoCommunity Champion
Anonymous no worries, you will get there 🙂
Not sure what exactly did you mean, but if you will write the exact requirment whenever you need it (you don't have to now), just open a new question and refer to this one and mention me.
Please don't forget to accept the previous message as a solution for community visibility.
P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas.
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂