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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BharatM
New Member

DAX - counting based on two columns

Hi,

 

I am fairly new to DAX. I have been struggling all day to solve a particular problem and would be grateful if someone can help guide me. I have a list of customers and data looks like this (dummy example):

 

Customer IDChoice
101Desk
101Chair
101Chair
102Chair
102Chair
103Desk
104Desk
104Chair
105Chair
105Chair
105Desk
105Chair
106

Desk

 

Eash customer can have multiple entries. However I want to extract only the ID of those customer who have chosen "Chair" only and nothing else - in this example 102 and 106. I have scratched my head and tried different thing and have failed. 

 

Thank you.

 

Bharat

1 ACCEPTED SOLUTION

@BharatM

 

I would suggest creating either a calculated column or measure using this code:

Chair only =
IF (
    CALCULATE (
        SELECTEDVALUE ( Choices[Choice] ),
        ALLEXCEPT ( Choices, Choices[Customer ID] )
    )
        = "Chair",
    1
)

Then apply a visual level filter (or any sort of filter in the case of a calculated column) Chair only = 1


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

4 REPLIES 4
harakuruku
Helper I
Helper I

Create a calculated column

 

IsChair = IF(Table1[Choice] = "Chair", 1, 0)

 

Then sum it in the display

Will this not also count those customer IDs who have chair and desk or table? I want only those customers who have chair and nothing else as a selection.

@BharatM

 

I would suggest creating either a calculated column or measure using this code:

Chair only =
IF (
    CALCULATE (
        SELECTEDVALUE ( Choices[Choice] ),
        ALLEXCEPT ( Choices, Choices[Customer ID] )
    )
        = "Chair",
    1
)

Then apply a visual level filter (or any sort of filter in the case of a calculated column) Chair only = 1


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

I can't thank you enough!!!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.