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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Add in additional filter condition in SUMMARIZE

I have a measure to count customers based on some criteria. Basically I want to find the excisting customer of product A, who started to buy product B and C. 

Measure = 
VAR _custA = 
SUMMARIZE (
    FILTER (orders,orders[product]= "A"),
    orders[customer ID],
    "Sales", SUM (orders[sales]))


RETURN
CALCULATE(
    DISTINCTCOUNT( orders[customer ID] ),
    FILTER ( _custA, [customer ID] = orders[customer ID]),FILTER (orders, orders[product] = "B" || orders[product] = "C" && orders[Cohort Date] == SELECTEDVALUE('Order Date'[Yr & mt])))

  

I want to add a new condition in VAR _custA, which is orders[date] < DATE(2021,12,1), because the launch of product B and C was in december.

 

I tried this but it doesnt show any values after the modification.

Measure = 
VAR _custA = 
SUMMARIZE (
    FILTER (orders,orders[product]= "A" && orders[date].[DATE]<DATE(2021,12,1)),
    orders[customer ID],
    "Sales", SUM (orders[sales]))


RETURN
CALCULATE(
    DISTINCTCOUNT( orders[customer ID] ),
    FILTER ( _custA, [customer ID] = orders[customer ID]),FILTER (orders, orders[product] = "B" || orders[product] = "C" && orders[Cohort Date] == SELECTEDVALUE('Order Date'[Yr & mt])))

 

Any idea on what the issue might be and how to fix it?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , try like

 

measure 1 = calculate(SUM (orders[sales]),FILTER (orders,orders[product]= "A" && orders[date]<DATE(2021,12,1)) )

or better use date table, you might need all to ignore selected filter
measure 1 = calculate(SUM (orders[sales]),FILTER (orders,orders[product]= "A"),FILTER (all(date), date[date]<DATE(2021,12,1))


Assuming date table is connected order date and this measure need selected date
Measure 2 = calculate(SUM (orders[sales]),FILTER (orders,orders[product] in {"B", "C"}) )


final meausre =
countx(values(orders[customer ID]), if ( not(isblank([measure 1]) ) && not(isblank([measure 2]) ) , [customer ID], blank())

 

 

same approch but for different product

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529
Customer Retention Part 2: Period over Period Retention :https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , try like

 

measure 1 = calculate(SUM (orders[sales]),FILTER (orders,orders[product]= "A" && orders[date]<DATE(2021,12,1)) )

or better use date table, you might need all to ignore selected filter
measure 1 = calculate(SUM (orders[sales]),FILTER (orders,orders[product]= "A"),FILTER (all(date), date[date]<DATE(2021,12,1))


Assuming date table is connected order date and this measure need selected date
Measure 2 = calculate(SUM (orders[sales]),FILTER (orders,orders[product] in {"B", "C"}) )


final meausre =
countx(values(orders[customer ID]), if ( not(isblank([measure 1]) ) && not(isblank([measure 2]) ) , [customer ID], blank())

 

 

same approch but for different product

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529
Customer Retention Part 2: Period over Period Retention :https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Perfect, thank you!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors