Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Sukh-ErdeneB
Frequent Visitor

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'.

 

SukhErdeneB_0-1678610592945.png

 

Looking forward to your help.

Regards

1 ACCEPTED SOLUTION
Anonymous
Not 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" )

vcgaomsft_0-1678760775577.png

 

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 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

View solution in original post

3 REPLIES 3
Anonymous
Not 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" )

vcgaomsft_0-1678760775577.png

 

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 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

thank you for your formula. It is great working.

Sukh-ErdeneB
Frequent Visitor

@Greg_Deckler  😅   @MFelix 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.