Forum Discussion
How to calculated 'nested' measures?
- 3 years ago
Hi, Sachintha
For your first need, show values (zeros) for employees who've never submitted a ticket.You just need to select this:
For your second need , here are the steps you can refer to .
We need to create a calculated column like this:
Year_month = YEAR([Date])*100+MONTH([Date])Then we can create a measure like this:
Measure = var _cur_year_month =CALCULATE( MAX('TicketList'[Year_month]), ALL('test2'[Manager])) var _em1= VALUES('test2'[Employee]) var _em2 = CALCULATETABLE( VALUES(test2[Employee]) , 'test2'[Manager] in _em1,ALLSELECTED('test2')) var _em3 = UNION(_em1,_em2) var _total = COUNTROWS(_em3) var _test =ADDCOLUMNS( CROSSJOIN( ALLSELECTED('test2'[Employee]) , ALLSELECTED('TicketList'[Year_month])) ,"flag" , CALCULATE(DISTINCTCOUNT('TicketList'[ID]),TREATAS({[Employee]},TicketList[Employee]),TREATAS({[Year_month]},'TicketList'[Year_month]) ,ALL('test2'[Manager]) )) var _t2 = FILTER(_test, [flag] <> BLANK() && [Year_month]=_cur_year_month && [Employee] in _em3) return COUNTROWS( _t2) / COUNTROWS(_em3)Then we can put this measure on the visual and we can meet your need:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi, Sachintha
For your first need, show values (zeros) for employees who've never submitted a ticket.You just need to select this:
For your second need , here are the steps you can refer to .
We need to create a calculated column like this:
Year_month = YEAR([Date])*100+MONTH([Date])
Then we can create a measure like this:
Measure =
var _cur_year_month =CALCULATE( MAX('TicketList'[Year_month]), ALL('test2'[Manager]))
var _em1= VALUES('test2'[Employee])
var _em2 = CALCULATETABLE( VALUES(test2[Employee]) , 'test2'[Manager] in _em1,ALLSELECTED('test2'))
var _em3 = UNION(_em1,_em2)
var _total = COUNTROWS(_em3)
var _test =ADDCOLUMNS( CROSSJOIN( ALLSELECTED('test2'[Employee]) , ALLSELECTED('TicketList'[Year_month])) ,"flag" , CALCULATE(DISTINCTCOUNT('TicketList'[ID]),TREATAS({[Employee]},TicketList[Employee]),TREATAS({[Year_month]},'TicketList'[Year_month]) ,ALL('test2'[Manager]) ))
var _t2 = FILTER(_test, [flag] <> BLANK() && [Year_month]=_cur_year_month && [Employee] in _em3)
return
COUNTROWS( _t2) / COUNTROWS(_em3)
Then we can put this measure on the visual and we can meet your need:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Sachintha3 years agoHelper III
v-yueyunzh-msft this worked perfectly, thanks!
However, I do not quite understand the complex measure, could you please explain it?