Forum Discussion

shouronpou's avatar
shouronpou
Copper Contributor
Jul 29, 2023
Solved

A Question about Power Query

I am making a task management chart using Excel. The chart has a detail sheet and a summary sheet. The detail sheet has columns for major category tasks, minor category tasks, and progress. The detai...
  • flexyourdata's avatar
    Jul 29, 2023

    shouronpou 

     

    You can use this query:

     

    let
        Source = Excel.CurrentWorkbook(){[Name="Detail"]}[Content],
    
        // Group by Major Tasks, return a list column called Progress containing the Progress values for that major task
        Groups = Table.Group(Source, {"Major Tasks"}, {{"Progress", each _[Progress]}}),
    
        /* Add a column that counts the distinct Progress values for each major task
        If the count is greater than 1, return "In progress"
        Otherwise the count is 1, return the first item (they're all the same)*/
        Result = Table.AddColumn(Groups, "Status", 
                    each 
                        if List.Count(
                                List.Distinct(_[Progress])
                            )>1 
                        then "In Progress" 
                        else _[Progress]{0}
                )[[Major Tasks], [Status]]
    in
        Result

     

    This will result in a summary table as shown in green:

     

     

Resources