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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
JustinDoh1
Post Prodigy
Post Prodigy

Overwrite the DISTINCTCOUNT as 0 if some other condition is met

I am trying to come up with DAX formula that goes like this:

 

If some condition is met, count as 1.

But if some other condition is met, count as 0.

 

How do we go about doing it?

Do we have to use VAR for each outcome and possibly subtract the each value (1 - 1 = 0)?

 

Bottom is graphic illustration:

JustinDoh1_0-1628878833810.png

 

 

Step1 = CALCULATE (
                             DISTINCTCOUNT( Table[ClientID] ),
                                  (Table[Step] = 1 &&
                                  Not(Table[Consent] = "Refused") &&
                                 NOT(ISBLANK(Table[Consent]))
                            )

 

Overwrite as Count 0 if bottom condition is met:
(
Table[Step] = 1 &&
NOT(Table[Consent] = "Not Eligible")
)

)

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@JustinDoh1 Maybe:

Column =
  VAR Step1 = CALCULATE (
                             DISTINCTCOUNT( Table[ClientID] ),
                                  (Table[Step] = 1 &&
                                  Not(Table[Consent] = "Refused") &&
                                 NOT(ISBLANK(Table[Consent]))
                            )
RETURN
  IF(Table[Step] = 1 && NOT(Table[Consent] = "Not Eligible"),0,Step1)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@JustinDoh1 That's just because you must have written a measure and the formula I wrote was for a column, hence why I called it column. SELECTEDVALUE will work although I tend to use MAX or MIN. But, remember, this is going to depend heavily on context for the measure to work properly.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@JustinDoh1 Maybe:

Column =
  VAR Step1 = CALCULATE (
                             DISTINCTCOUNT( Table[ClientID] ),
                                  (Table[Step] = 1 &&
                                  Not(Table[Consent] = "Refused") &&
                                 NOT(ISBLANK(Table[Consent]))
                            )
RETURN
  IF(Table[Step] = 1 && NOT(Table[Consent] = "Not Eligible"),0,Step1)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler I have a question for you.

Your code was great, but I had to add "SelectedValue" or it appears that I had to aggregate to get rid of error. How do I fix to select only one value?  Because error was gone, but I don't think my logic goes thru though. Thanks.

JustinDoh1_0-1629154691832.png

 

 

 

@JustinDoh1 That's just because you must have written a measure and the formula I wrote was for a column, hence why I called it column. SELECTEDVALUE will work although I tend to use MAX or MIN. But, remember, this is going to depend heavily on context for the measure to work properly.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thank you so much! It worked.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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