The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
but I want to count consecutive value by FACT_OT[PERIOD] , If it is a consecutive month, it will be counted.
Result :
EMP_CODE: 01329 ---> Consecutive = 2
EMP_CODE: 04583 ---> Consecutive = 6
Solved! Go to Solution.
Hi @newyearrrr
First you need to sort the period column:
MonthRank =
RANKX(
FILTER(
FACT_OT,
FACT_OT[EMP_CODE] = EARLIER(FACT_OT[EMP_CODE])
),
FACT_OT[PERIOD],
,
ASC,
Dense
)
Then you need to combined and sort the EMP_CODE and MonthRank column:
Combined = [EMP_CODE]&"-"&[MonthRank]
Then you can use the following Measure to get the result you want:
Measure =
VAR current_emp = SELECTEDVALUE(FACT_OT[EMP_CODE])
VAR current_month = CALCULATE(SELECTEDVALUE(FACT_OT[month]),FILTER('FACT_OT','FACT_OT'[EMP_CODE] = current_emp))
VAR current_rank = SELECTEDVALUE(FACT_OT[MonthRank])
VAR previous_month = CALCULATE(SELECTEDVALUE(FACT_OT[month]),FILTER(ALL('FACT_OT'),'FACT_OT'[MonthRank]=current_rank-1&&'FACT_OT'[EMP_CODE] = current_emp))
VAR next_month = CALCULATE(SELECTEDVALUE(FACT_OT[month]),FILTER(ALL('FACT_OT'),'FACT_OT'[MonthRank]=current_rank+1&&'FACT_OT'[EMP_CODE] = current_emp))
RETURN
IF(current_month - previous_month = 1||next_month-current_month=1,1,BLANK())
Result:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @newyearrrr
First you need to sort the period column:
MonthRank =
RANKX(
FILTER(
FACT_OT,
FACT_OT[EMP_CODE] = EARLIER(FACT_OT[EMP_CODE])
),
FACT_OT[PERIOD],
,
ASC,
Dense
)
Then you need to combined and sort the EMP_CODE and MonthRank column:
Combined = [EMP_CODE]&"-"&[MonthRank]
Then you can use the following Measure to get the result you want:
Measure =
VAR current_emp = SELECTEDVALUE(FACT_OT[EMP_CODE])
VAR current_month = CALCULATE(SELECTEDVALUE(FACT_OT[month]),FILTER('FACT_OT','FACT_OT'[EMP_CODE] = current_emp))
VAR current_rank = SELECTEDVALUE(FACT_OT[MonthRank])
VAR previous_month = CALCULATE(SELECTEDVALUE(FACT_OT[month]),FILTER(ALL('FACT_OT'),'FACT_OT'[MonthRank]=current_rank-1&&'FACT_OT'[EMP_CODE] = current_emp))
VAR next_month = CALCULATE(SELECTEDVALUE(FACT_OT[month]),FILTER(ALL('FACT_OT'),'FACT_OT'[MonthRank]=current_rank+1&&'FACT_OT'[EMP_CODE] = current_emp))
RETURN
IF(current_month - previous_month = 1||next_month-current_month=1,1,BLANK())
Result:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
28 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
36 | |
14 | |
12 | |
8 | |
7 |