Forum Discussion

upniwesh's avatar
upniwesh
Regular Visitor
3 years ago
Solved

Display line graph for two data from one table

I have one Excel sheet from where I am preparing the Dashboard. I have data like below  Task Name Target Date Alert Date Task 1 13/06/2023 13/09/2023 Task 2 05/05/2023 10/08/2023 ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi upniwesh ,

     

    Here's my solution in Power Query. 

    1.Create a calendar table and extract months.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtY11DVUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [StartDate = _t]),
        #"Added Custom" = Table.AddColumn(Source, "EndDate", each Date.From("2023-12-31")),
        #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom",{{"EndDate", type date}}),
        #"Changed Type" = Table.TransformColumnTypes(#"Changed Type2",{{"StartDate", type date}}),
        #"Added Custom1" = Table.AddColumn(#"Changed Type", "Dates", each {Number.From([StartDate])..Number.From([EndDate])}),
        #"Expanded Dates" = Table.ExpandListColumn(#"Added Custom1", "Dates"),
        #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Dates",{{"Dates", type date}}),
        #"Removed Columns1" = Table.RemoveColumns(#"Changed Type1",{"StartDate", "EndDate"}),
        #"Added Custom4" = Table.AddColumn(#"Removed Columns1", "MonthName", each Date.MonthName([Dates])),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom4",{"Dates"}),
        #"Removed Duplicates" = Table.Distinct(#"Removed Columns")
    in
        #"Removed Duplicates"

     

    2.Create two month name column and a custom column contains 1 in the main table.

    =Date.MonthName([Target Date])
    =Date.MonthName([Alert Date])

     

     

    3.In Query1, click "Merge Queries".

    Merge with the main table as follows.

     

    4.Expand the custom column contains 1.

     

     

    5.Merge again, replacing the matching column with Alert Month. After the merger is complete, expand the Alert Month column.

     

     

    6.Group by MonthName and sum two columns.

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

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