Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
8 |