Forum Discussion
Need a help on filter formula
Hey Guys,
I need help on shaping a formula in a picture below. Instead of filtering them out by hands in blue table.
I'm trying to count the same value in 'TcodeDesc' as 1 with the filter of same value in 'TimeComponent', when the starting time of 7:00 AM and ending time of 19:00 PM are continuous in column 'DateTimeEnd' and 'DateTimeStart'.
Looking forward to your help.
Regards
- Anonymous3 years ago
Hi Sukh-ErdeneB ,
Please create these new measures as follows.
ULF Count = CALCULATE( DISTINCTCOUNT('Table'[TimeComponent]), 'Table'[TimeComponent] = "ULF" )OL Count = CALCULATE( DISTINCTCOUNT('Table'[TimeComponent]), 'Table'[TimeComponent] = "OL" )AM Count = CALCULATE( DISTINCTCOUNT('Table'[TimeComponent]), 'Table'[TimeComponent] = "AM" )Or have a look at these steps in the PQ.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCvYwMDBU0lEKLkksKgHSoT5uSrE6RIhXFpek5uKT8PdBEXfLLErFojw8sSS1iEhxIyDfOT+vpCg/B8hy9MUhga4lOCQo1DkkNMgV1VEgKd/80jy472IB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Unit = _t, TCodeDesc = _t, TimeComponent = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Unit", type text}, {"TCodeDesc", type text}, {"TimeComponent", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"TCodeDesc", "TimeComponent"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}}), #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[TimeComponent]), "TimeComponent", "Count", List.Sum) in #"Pivoted Column"Best Regards,
Gao
Community Support TeamIf 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
3 Replies
- AnonymousNot applicable
Hi Sukh-ErdeneB ,
Please create these new measures as follows.
ULF Count = CALCULATE( DISTINCTCOUNT('Table'[TimeComponent]), 'Table'[TimeComponent] = "ULF" )OL Count = CALCULATE( DISTINCTCOUNT('Table'[TimeComponent]), 'Table'[TimeComponent] = "OL" )AM Count = CALCULATE( DISTINCTCOUNT('Table'[TimeComponent]), 'Table'[TimeComponent] = "AM" )Or have a look at these steps in the PQ.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCvYwMDBU0lEKLkksKgHSoT5uSrE6RIhXFpek5uKT8PdBEXfLLErFojw8sSS1iEhxIyDfOT+vpCg/B8hy9MUhga4lOCQo1DkkNMgV1VEgKd/80jy472IB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Unit = _t, TCodeDesc = _t, TimeComponent = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Unit", type text}, {"TCodeDesc", type text}, {"TimeComponent", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"TCodeDesc", "TimeComponent"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}}), #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[TimeComponent]), "TimeComponent", "Count", List.Sum) in #"Pivoted Column"Best Regards,
Gao
Community Support TeamIf 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
- Sukh-ErdeneBFrequent Visitor
thank you for your formula. It is great working.
- Sukh-ErdeneBFrequent Visitor
Greg_Deckler 😅 MFelix