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

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

Reply
H_insight
Helper V
Helper V

Count with condition per customer per id

 

Hiya,

 

I am trying to write a measure to count the Products per customer and per id, where the "Product" column = "Product 1" and does not contain any "Product 2" for the same ID.

here s my attempt

 

 

Measure = 
CALCULATE(COUNTA(Table1[Product]),
        FILTER(Table1, Table1[Product] = "Product 1"), FILTER(Table1, 
 NOT(CONTAINSSTRING(Table1[Product],"Product 2"))))

 

 

I am getting the result count of 3, but I am looking only for 2 as a result (example below)

H_insight_0-1667481404169.png

 

Sample Data:

IdCustomerProduct

1Customer 1Product 1
1Customer 1Product 2
1Customer 1Product 3
1Customer 1Product 4
2Customer 1Product 1
2Customer 1Product 4
2Customer 1Product 5
3Customer 1Product 1
3Customer 1Product 8
3Customer 1Product 3
3Customer 1Product 4

 

Thanks

1 ACCEPTED SOLUTION

Hi,

thank you for your feedback.

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1667489566510.png

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
H_insight
Helper V
Helper V

Hi @Jihwan_Kim ,

 

I am still getting the same result for 3 records, and my goal is to show only 2 records

H_insight_0-1667485954286.png

Goal:

H_insight_1-1667486079646.png

 

Hi,

thank you for your feedback.

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1667489566510.png

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim Super Star🌟!! Thank you very much. I have to say, formatting DAX does help a lot in understanding the logic behind the code. 👍

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file, whether it suits your requirement.

 

Jihwan_Kim_0-1667484151913.png

 

 

Expected result measure: =
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            DISTINCT ( 'Table'[Id] ),
            "@productonecondition", CALCULATE ( COUNTROWS ( FILTER ( 'Table', 'Table'[Product] = "Product 1" ) ) ),
            "@producttwocondition", CALCULATE ( COUNTROWS ( FILTER ( 'Table', 'Table'[Product] = "Product 2" ) ) )
        ),
        [@productonecondition] >= 1
            && [@producttwocondition] = 0
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.