Forum Discussion

karim2026's avatar
karim2026
Regular Visitor
3 months ago
Solved

Insert row for missing repeating sequence in a table

I have a time stamp table with a repeating sequence column (90, 91, 92, 93 and repeat), some of the sequences are missing.

I am trying to find the missing value and insert a new row with that value in the column

any help would be appreciated

 

DateTime Machine# Mode Sequence
2026-01-05T07:23:00.261GSB0193
2026-01-05T07:23:39.479GSB0190
2026-01-05T07:25:03.896GSB0191
2026-01-05T07:37:14.519GSB0192
2026-01-05T07:40:43.126GSB0193
2026-01-06T09:49:12.376GSB0191
2026-01-06T10:00:01.121GSB0192
2026-01-06T10:02:01.825GSB0193
2026-01-06T10:12:41.143GSB0190
2026-01-06T10:14:41.883GSB0191
2026-01-06T10:26:42.770GSB0192
 
the mode sequence should be 90, 91, 92, 93 and repeats
 

I am trying to find the missing mode sequence and insert a row with the missing sequence value

 
DateTime Machine# Mode Sequence
2026-01-05T07:23:00.261GSB0193
2026-01-05T07:23:39.479GSB0190
2026-01-05T07:25:03.896GSB0191
2026-01-05T07:37:14.519GSB0192
2026-01-05T07:40:43.126GSB0193
  90
2026-01-06T09:49:12.376GSB0191
2026-01-06T10:00:01.121GSB0192
2026-01-06T10:02:01.825GSB0193
2026-01-06T10:12:41.143GSB0190
2026-01-06T10:14:41.883GSB0191
2026-01-06T10:26:42.770GSB0192

 

Thanks,

  • karim2026's avatar
    karim2026
    3 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

3 Replies

  • 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




     

    • karim2026's avatar
      karim2026
      Regular Visitor

      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-msft's avatar
        v-nmadadi-msft
        Community 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