Forum Discussion
greenmonsta
4 years agoFrequent Visitor
count data across mutiple ranges
Hi All, I am trying to solve the following in Power Query. In the data table I have Ticket Number, the date the ticket was created and the date the ticket was resolved. If the resolved cell is blan...
- 4 years ago
Hi greenmonsta ,
didn't get that requirement before.
You can adjust like this:let Source = Sprints, #"Added Custom" = Table.AddColumn( Source, "Days", each {Number.From([Start]) .. Number.From([End])} ), #"Expanded Days" = Table.ExpandListColumn(#"Added Custom", "Days"), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Days", {{"Days", type date}}), Merge = Table.NestedJoin( #"Changed Type", {"Days"}, Tickets_Exanded, {"Dates"}, "Starts", JoinKind.LeftOuter ), Expanded = Table.ExpandTableColumn(Merge, "Starts", {"Ticket Num", "Opened Date", "Closed Date"}, {"Ticket Num", "Opened Date", "Closed Date"}), AddOpened = Table.AddColumn(Expanded, "Opened", each if [Days] = [Opened Date] then [Opened Date] else null), AddClosed = Table.AddColumn(AddOpened, "Closed", each if [Days] = [Closed Date] then [Closed Date] else null), AddIgnoreForOpen = Table.AddColumn(AddClosed, "IgnoreForOpen", each [Opened Date] >= [Start] and [Closed Date] <= [End]), #"Grouped Rows" = Table.Group( AddIgnoreForOpen, {"Sprint", "Start", "End"}, { { "Tickets Created", each List.Count(List.Distinct(List.Select(_[Opened], each _ <> null))), Int64.Type }, { "Tickets Closed", each List.Count(List.Distinct(List.Select(_[Closed], each _ <> null))), Int64.Type }, {"Tickets Open", each List.Count(List.Distinct(Table.SelectRows(_, (x) => not x[IgnoreForOpen])[Ticket Num])), Int64.Type} } ) in #"Grouped Rows"
Also check enclosed file.
Greg_Deckler
4 years agoCommunity Champion
greenmonsta I don't have a Power Query solution for this but I did create a DAX solution for this a long time ago.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
greenmonsta
4 years agoFrequent Visitor
Hey Greg, Thanks for the fast reponse. I really need it in Power Query but I am looking at the Dax. Maybe I can get some hints out ot there to apply to my M code.
- Greg_Deckler4 years agoCommunity Champion
greenmonsta Yeah, I'm not sure how you would go about that in Power Query. Maybe ImkeF has some thoughts.