Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 11 | |
| 10 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 33 | |
| 30 | |
| 19 | |
| 12 | |
| 11 |