Forum Discussion

larrylob's avatar
larrylob
Regular Visitor
5 years ago
Solved

Create sequential numbering that restarts daily

Hello,

 

I have data being inputed daily by a Form for different department's next day plans. There are multiple plans being subitted for multiple work areas. I am trying to create a column in PowerQuery that would add a seqential number to each work area sort of like the output column in the table below.

 

DateDisciplineWork AreaOutput
6-JulDiscipline 1Area 1Area 1 - 1
6-JulDiscipline 2Area 1Area 1 - 2
6-JulDiscipline 1Area 2Area 2 - 1
6-JulDiscipline 4Area 1Area 1 - 3
6-JulDiscipline 3Area 2Area 2 - 2
6-JulDiscipline 4Area 2Area 2 - 3
6-JulDiscipline 2Area 3Area 3 - 1

 

I would also want the sequential number to restart when the date changes. The point of this is that I could have cards on a dashboard be populated with the data from the same Area sequential number that would just update to today's date.

 

I hope this makes sense.

 

Thanks!

  • Hi larrylob ,

    You can try this query:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtP1Ks1R0lFyySxOzizIycxLVTAEch2LUhOBjFgdrCqMCKqAm2GES4UJQTOMiTcDpwq4S43BKiwJ+haLCiOCKtB8i0WFCUEzjIk3A6cKZN/GAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Discipline = _t, #"Work Area" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Discipline", type text}, {"Work Area", type text}}),
        #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] = Date.From(DateTime.LocalNow())),
        #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Work Area", Order.Ascending}, {"Discipline", Order.Ascending}}),
        #"Grouped Rows" = Table.Group(#"Sorted Rows", {"Date", "Work Area"}, {{"Data", each Table.AddIndexColumn(_,"Index",1,1), type table [Date=nullable date, Discipline=nullable text, Work Area=nullable text]}}),
        #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Discipline","Index"}, {"Discipline","Index"}),
        #"Added Custom" = Table.AddColumn(#"Expanded Data", "Output", each [Work Area] & " - " & Text.From([Index]),type text),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
    in
        #"Removed Columns"

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • v-yingjl's avatar
    v-yingjl
    Icon for Community Support rankCommunity Support

    Hi larrylob ,

    You can try this query:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtP1Ks1R0lFyySxOzizIycxLVTAEch2LUhOBjFgdrCqMCKqAm2GES4UJQTOMiTcDpwq4S43BKiwJ+haLCiOCKtB8i0WFCUEzjIk3A6cKZN/GAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Discipline = _t, #"Work Area" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Discipline", type text}, {"Work Area", type text}}),
        #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] = Date.From(DateTime.LocalNow())),
        #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Work Area", Order.Ascending}, {"Discipline", Order.Ascending}}),
        #"Grouped Rows" = Table.Group(#"Sorted Rows", {"Date", "Work Area"}, {{"Data", each Table.AddIndexColumn(_,"Index",1,1), type table [Date=nullable date, Discipline=nullable text, Work Area=nullable text]}}),
        #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Discipline","Index"}, {"Discipline","Index"}),
        #"Added Custom" = Table.AddColumn(#"Expanded Data", "Output", each [Work Area] & " - " & Text.From([Index]),type text),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
    in
        #"Removed Columns"

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.