Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
Hi Guys,
I need a help with the case below:
How to write it in Dax or Powerquery a code like this below:
Expected Result =
VAR V_ID = 1
RETURN
if('Table'[OverflowAlarm] = 1 && 'Table'[Previus row] = 0, V_ID,
if('Table'[OverflowAlarm] = 0 && 'Table'[Previus row] = 1, V_ID = V_ID +1 ,
if ('Table'[OverflowAlarm] = 1 && 'Table'[Previus row] = 1, 'Table'[OverflowAlarm],0
)))
I have a table like that:
| Time/date | Point_Id | Index | Duration | OverflowAlarm | Previus row |
| 14/03/2018 23:45 | PDD11148 | 78241 | 15 | 1 | |
| 14/03/2018 23:30 | PDD11148 | 78242 | 15 | 1 | 1 |
| 14/03/2018 23:15 | PDD11148 | 78243 | 15 | 1 | 1 |
| 14/03/2018 23:00 | PDD11148 | 78244 | 15 | 1 | 1 |
| 14/03/2018 22:45 | PDD11148 | 78245 | 15 | 1 | 1 |
| 14/03/2018 22:30 | PDD11148 | 78246 | 15 | 1 | 0 |
| 14/03/2018 22:15 | PDD11148 | 78247 | 0 | 0 | 0 |
| 14/03/2018 22:00 | PDD11148 | 78248 | 0 | 0 | 0 |
| 14/03/2018 21:45 | PDD11148 | 78249 | 0 | 0 | 0 |
| 14/03/2018 21:30 | PDD11148 | 78250 | 0 | 0 | 0 |
| 14/03/2018 21:15 | PDD11148 | 78251 | 0 | 0 | 0 |
| 14/03/2018 21:00 | PDD11148 | 78252 | 0 | 0 | 0 |
| 14/03/2018 20:45 | PDD11148 | 78253 | 0 | 0 | 1 |
| 14/03/2018 20:30 | PDD11148 | 78254 | 15 | 1 | 0 |
| 14/03/2018 20:15 | PDD11148 | 78255 | 0 | 0 | 1 |
| 14/03/2018 20:00 | PDD11148 | 78256 | 15 | 1 | 1 |
| 14/03/2018 19:45 | PDD11148 | 78257 | 15 | 1 | 1 |
| 14/03/2018 19:30 | PDD11148 | 78258 | 15 | 1 | 1 |
| 14/03/2018 19:15 | PDD11148 | 78259 | 15 | 1 | 1 |
| 14/03/2018 19:00 | PDD11148 | 78260 | 15 | 1 | 1 |
And that is the result that I need:
| Point_Id | Index | Duration | OverflowAlarm | Previus row | Expected Result |
| PDD11148 | 78241 | 15 | 1 | event 1 | |
| PDD11148 | 78242 | 15 | 1 | 1 | event 1 |
| PDD11148 | 78243 | 15 | 1 | 1 | event 1 |
| PDD11148 | 78244 | 15 | 1 | 1 | event 1 |
| PDD11148 | 78245 | 15 | 1 | 1 | event 1 |
| PDD11148 | 78246 | 15 | 1 | 0 | event 1 |
| PDD11148 | 78247 | 0 | 0 | 0 | |
| PDD11148 | 78248 | 0 | 0 | 0 | |
| PDD11148 | 78249 | 0 | 0 | 0 | |
| PDD11148 | 78250 | 0 | 0 | 0 | |
| PDD11148 | 78251 | 0 | 0 | 0 | |
| PDD11148 | 78252 | 0 | 0 | 0 | |
| PDD11148 | 78253 | 0 | 0 | 1 | |
| PDD11148 | 78254 | 15 | 1 | 0 | event 2 |
| PDD11148 | 78255 | 0 | 0 | 1 | |
| PDD11148 | 78256 | 15 | 1 | 1 | event 3 |
| PDD11148 | 78257 | 15 | 1 | 1 | event 3 |
| PDD11148 | 78258 | 15 | 1 | 1 | event 3 |
| PDD11148 | 78259 | 15 | 1 | 1 | event 3 |
| PDD11148 | 78260 | 15 | 1 | 1 | event 3 |
Any help is welcome!
Thanks
They've surrounded us. thanks for all you have done
@Anonymous ,
You may take a look at the post below.
Hi,
@v-chuncz-msft wrote:@Anonymous ,
You may take a look at the post below.
Thanks for your response.
I am not a Power Bi expert, I've been working only few weeks with it. But, I couldn't see it working for me. And the function earlier doesn't work well... too many rows in the table, it runs forever... Any other solution?
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 |
|---|---|
| 79 | |
| 48 | |
| 35 | |
| 31 | |
| 27 |