Forum Discussion

Masf91's avatar
Masf91
New Member
2 years ago
Solved

Add missing items at day level

Hi, I have a problem. My requirement is based on having all the existing elements every day. I attach an excel image with my current situation and what I expect.

 

 

  • Hi Masf91 
    You can achieve it with power query .
    1. Duplicate the table

    2. At the first table Remove Fecha column
    At the second elementos

    2. Rename the result 2 tables to Fecha and elemenots

    3. Remove Duplicates from both

    4. Go to Fecha table and add custom column with the name of the second + expand the table

    4. uncheck the "enable load" of the Elementos table

    pbix is attached you can follow my steps

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

5 Replies

  • Hi,

    If you have 2 tables - Fecha and Elementos (only 1 column in each table), then in the Fecha Table, you can write this custom column formula in the Power Query Editor

    =Elementos

    Expand the column.

    Hope this helps.

  • Hi Masf91 
    You can achieve it with power query .
    1. Duplicate the table

    2. At the first table Remove Fecha column
    At the second elementos

    2. Rename the result 2 tables to Fecha and elemenots

    3. Remove Duplicates from both

    4. Go to Fecha table and add custom column with the name of the second + expand the table

    4. uncheck the "enable load" of the Elementos table

    pbix is attached you can follow my steps

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Masf91 ,

    Please try:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJR0lFyBGJDA6VYHRRRJ5CoIbqoM0jUGCpqhKLWBF0UrNYCKmqMbJulUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Elementos = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Elementos", type text}, {"Value", Int64.Type}}),
        datetable = Table.FromList(List.Transform({Number.From(List.Min(#"Changed Type"[Date]))..Number.From(List.Max(#"Changed Type"[Date]))},Date.From), Splitter.SplitByNothing(), {"Date"}),
        elementostable = Table.Distinct(Table.SelectColumns(#"Changed Type","Elementos")),
        Custom1 = Table.AddColumn(datetable, "custom", each elementostable),
        #"Expanded custom" = Table.ExpandTableColumn(Custom1, "custom", {"Elementos"}, {"Elementos"}),
        #"Merged Queries" = Table.NestedJoin(#"Expanded custom", {"Date", "Elementos"}, #"Changed Type", {"Date", "Elementos"}, "Expanded custom", JoinKind.LeftOuter),
        #"Expanded Expanded custom" = Table.ExpandTableColumn(#"Merged Queries", "Expanded custom", {"Value"}, {"Value"})
    in
        #"Expanded Expanded custom"

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group