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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
georgec96
Helper II
Helper II

FILTER IN GROUP BY

Hi everyone,

 

I just started working with DAX and I came across something and I'm a bit stuck.

 

Is there any way to use a filter function when using group by? I've been searching for it for days but couldn't find anything.

 

I would like to group my data by date, usr_id, shift, rate_type and

 

do a sum of the total seconds column where column rate type starts with "replens" and column actcod="GENMOV" and "CASRPL"

do a count of rows where column actcod = "CASRPL" and column Time over/under = "Time Under 5".

 

What i am struggling to understand is how to apply a different fitler for those 2 aggregations 
I want a filter on sum and a different filter on count.

 

georgec96_0-1647190916708.png

 

Thanks.

 

1 ACCEPTED SOLUTION
Whitewater100
Solution Sage
Solution Sage

Hello:

Here is one way to do this. 

TWO CALC COLUMNS

A = IF(
   AND( LEFT( Table[rate-type], 7) = “replens”,
       Table[actcod] = “GENMOV”),
   SUM(Table[Total Seconds], BLANK()
)

 

B =IF(

   AND(Table[actcod] = “CASRPL”,

       Table[Time over/under] = “Time Under 5”),

   1), BLANK()

)

 

TWO Measures

Sum A = SUM(Table[A])

SumB =SUM(Table[B])

 

You could potentially just have two measures where you can have variables for the conditions

But here you can see what is occurring a bit easier.

View solution in original post

1 REPLY 1
Whitewater100
Solution Sage
Solution Sage

Hello:

Here is one way to do this. 

TWO CALC COLUMNS

A = IF(
   AND( LEFT( Table[rate-type], 7) = “replens”,
       Table[actcod] = “GENMOV”),
   SUM(Table[Total Seconds], BLANK()
)

 

B =IF(

   AND(Table[actcod] = “CASRPL”,

       Table[Time over/under] = “Time Under 5”),

   1), BLANK()

)

 

TWO Measures

Sum A = SUM(Table[A])

SumB =SUM(Table[B])

 

You could potentially just have two measures where you can have variables for the conditions

But here you can see what is occurring a bit easier.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.