Forum Discussion
Insert row for missing repeating sequence in a table
- 4 months ago
Thanks
Previous solution from AlienSX with List.Generate and calculate next sequence number each time with a help of Number.Mod. worked and is very concise code
Hi karim2026
Thanks for reaching out to the Microsoft Fabric Community forum.
I was able to get the required output using the below DAX, Please try it
FinalTable2 =
VAR Base =
ADDCOLUMNS(
'BaseTable',
"NextDateTime",
CALCULATE(
MIN('BaseTable'[DateTime]),
FILTER(
ALL('BaseTable'),
'BaseTable'[DateTime] > EARLIER('BaseTable'[DateTime]) &&
'BaseTable'[Machine #] = EARLIER('BaseTable'[Machine #])
)
)
)
VAR WithNext =
ADDCOLUMNS(
Base,
"NextSeq",
LOOKUPVALUE(
'BaseTable'[Mode Sequence],
'BaseTable'[DateTime], [NextDateTime],
'BaseTable'[Machine #], [Machine #]
),
"ExpectedNext",
SWITCH(
[Mode Sequence],
90, 91,
91, 92,
92, 93,
93, 90
)
)
VAR MissingRows =
SELECTCOLUMNS(
FILTER(
WithNext,
NOT ISBLANK([NextSeq]) &&
[NextSeq] <> [ExpectedNext]
),
"DateTime", BLANK(),
"Machine#", [Machine #],
"Mode Sequence", [ExpectedNext]
)
RETURN
UNION(
SELECTCOLUMNS(
'BaseTable',
"DateTime", [DateTime],
"Machine#", [Machine #],
"Mode Sequence", [Mode Sequence]
),
MissingRows
)
Uploading the .pbix file for reference as well.
I hope this information helps. Please do let us know if you have any further queries.
Thank you
Thanks
Previous solution from AlienSX with List.Generate and calculate next sequence number each time with a help of Number.Mod. worked and is very concise code
- v-nmadadi-msft4 months agoCommunity Support
Hi karim2026 ,
We really appreciate your efforts and for letting us know the update on the issue.
Please continue using fabric community forum for your further assistance.
Regards