This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi Guys,.
I need some help with my DAX. I want to flag a record by count back days, if is the same ean, store, and stock if stock [date] = stock[previous N days].
This is a sample data:
Another example:
Could you help me please?
Best!
Solved! Go to Solution.
I think that you want something like:
Column =
VAR __minDate = [date] - 2
VAR __table = FILTER(ALL('Table'),[date]<=EARLIER([date]) && [date]>=__minDate && [store]=EARLIER([store]) && [item]=EARLIER([item]))
VAR __val2day = MAXX(FILTER(__table,[date]=EARLIER([date])-2),[stock qty])
VAR __val1day = MAXX(FILTER(__table,[date]=EARLIER([date])-1),[stock qty])
RETURN
IF(__val2day = [stock qty] && __val1day = [stock qty],1,0)
Hi @jmolina,
If you mean mark tag of same store amount, you can try to use following calculated column formula:
Continuous Tag =
VAR prev =
LOOKUPVALUE (
'Table'[STOCK],
'Table'[STORE], [STORE],
'Table'[EAN], [EAN],
'Table'[Date], [Date] - 1
)
VAR next =
LOOKUPVALUE (
'Table'[STOCK],
'Table'[STORE], [STORE],
'Table'[EAN], [EAN],
'Table'[Date], [Date] + 1
)
RETURN
IF ( [STOCK] IN { prev, next }, 1, 0 )
Regards,
Xiaoxin Sheng
I'm not understanding the logic of when something is 1 or 0.
Hi,.
I need to flag (1, 0) if the stock quantity maintains static in the last 3 consecutive days, for the same item and store
i have updated my post with other example table. Thanks a lot.
Best!
I think that you want something like:
Column =
VAR __minDate = [date] - 2
VAR __table = FILTER(ALL('Table'),[date]<=EARLIER([date]) && [date]>=__minDate && [store]=EARLIER([store]) && [item]=EARLIER([item]))
VAR __val2day = MAXX(FILTER(__table,[date]=EARLIER([date])-2),[stock qty])
VAR __val1day = MAXX(FILTER(__table,[date]=EARLIER([date])-1),[stock qty])
RETURN
IF(__val2day = [stock qty] && __val1day = [stock qty],1,0)
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 30 | |
| 28 | |
| 23 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 49 | |
| 47 | |
| 40 | |
| 21 | |
| 18 |