The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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:
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")
)
)
Solved! Go to Solution.
@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)
@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.
@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)
@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 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.
User | Count |
---|---|
16 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
23 | |
13 | |
13 | |
8 | |
8 |