Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi there,
I have measures for Percent, and Percent previous day. I also have a measure to flag if the daily change went up or down.
What I am wanting to do is write a measure that counts the number of days between the start of each change, as shown in the image.
Can you please assist me in helping to write this measure? Thanks.
Solved! Go to Solution.
Hi @greenskmachine2 ,
Check the following measure:
Consecutive Days Measure =
VAR CurrentDate = MAX('Table'[Date])
VAR CurrentFlag = MAX('Table'[Percent Change Flag])
VAR PreviousDates =
FILTER(
ALL('Table'),
'Table'[Date] < CurrentDate
)
VAR LastChangeDate =
MAXX(
FILTER(
PreviousDates,
'Table'[Percent Change Flag] <> CurrentFlag
),
'Table'[Date]
)
VAR StartDate =
IF(ISBLANK(LastChangeDate), MIN('Table'[Date]), LastChangeDate)
VAR ConsecutiveDays =
DATEDIFF(StartDate, CurrentDate, DAY)
RETURN
IF(NOT ISBLANK(CurrentFlag), ConsecutiveDays, BLANK())
Result:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @greenskmachine2 ,
Check the following measure:
Consecutive Days Measure =
VAR CurrentDate = MAX('Table'[Date])
VAR CurrentFlag = MAX('Table'[Percent Change Flag])
VAR PreviousDates =
FILTER(
ALL('Table'),
'Table'[Date] < CurrentDate
)
VAR LastChangeDate =
MAXX(
FILTER(
PreviousDates,
'Table'[Percent Change Flag] <> CurrentFlag
),
'Table'[Date]
)
VAR StartDate =
IF(ISBLANK(LastChangeDate), MIN('Table'[Date]), LastChangeDate)
VAR ConsecutiveDays =
DATEDIFF(StartDate, CurrentDate, DAY)
RETURN
IF(NOT ISBLANK(CurrentFlag), ConsecutiveDays, BLANK())
Result:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 16 | |
| 8 | |
| 7 | |
| 7 |