March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I need to identify any row when the Value goes over a set threshold for 3 or more consecutive days.
Example data - each ID is repeated once for each Date. If the Value exceeds 4 over a consecutive 3 day period then I need to mark it somehow.
How do I add a column for this?
Here's the type of output I'm looking for - please advise 🙂
Solved! Go to Solution.
Flag =
VAR __id = DATA[ID]
VAR __pos =
MAXX(
FILTER(
DATA,
DATA[ID] = __id
&& DATA[Date] <= EARLIER( DATA[Date] )
&& DATA[Value] <= 4
),
DATA[Date]
)
RETURN
IF(
DATA[Date]
- IF(
ISBLANK( __pos ),
MINX( FILTER( DATA, DATA[ID] = __id ), DATA[Date] ) - 1,
__pos
) >= 3,
"YES"
)
For fun only, to show off the power of Excel worksheet formula,
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Thanks both @VahidDM and @CNENFRNL for your quick responses! Kudos to both 🏆🏆
I've used the verison from @CNENFRNL it seems to work a bit better, or simply more understable to my noob brain.
However, it doesn't seem to handle gaps in the date range, but nvm I've adapted so that there's no gaps by adding any missing dates and zero values.
I've also added modified versions of your solution to show the first date on which the threshold was met so that I can answer questions like "when did it start going over threshold" or "for how long has it been over threshold"
Many thanks both :):)
Flag =
VAR __id = DATA[ID]
VAR __pos =
MAXX(
FILTER(
DATA,
DATA[ID] = __id
&& DATA[Date] <= EARLIER( DATA[Date] )
&& DATA[Value] <= 4
),
DATA[Date]
)
RETURN
IF(
DATA[Date]
- IF(
ISBLANK( __pos ),
MINX( FILTER( DATA, DATA[ID] = __id ), DATA[Date] ) - 1,
__pos
) >= 3,
"YES"
)
For fun only, to show off the power of Excel worksheet formula,
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi @DDDDD
Try this measure:
Warning =
Var _CD = MAX('Table'[Date])
Var _CD_1 = _CD-1
Var _CD_2 = _CD-2
Var _A = MAX('Table'[Value])
Var _B = CALCULATE(MAX('Table'[Value]),REMOVEFILTERS('Table'[Date]),'Table'[Date]=_CD_1)
Var _C = CALCULATE(MAX('Table'[Value]),REMOVEFILTERS('Table'[Date]),'Table'[Date]=_CD_2)
return
IF(_A>4&&_B>4&&_C>4,"Yes","No")
Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
FIFA Word Cup Medal Records Dashboard:
Interesting method; but what if 30 consecutive days ...
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
That measure will manage 30 consecutive days as well:
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
FIFA Word Cup Medal Records Dashboard:
https://community.powerbi.com/t5/Charticulator-Design-Challenge/FIFA-World-Cup-Medal-Records/cns-p/2...
I mean, flag the column after 30 consecutive records of a streak; take your own mockup for instance, from 2022/5/30 and onwards.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Not sure I got your point correctly or not, but FYI:
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hmm... start marking "yes" from 5/30.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Yes, because 1-Jun-22 is still in 3 days consecutive period.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
106 | |
98 | |
65 | |
54 |