Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Solved! Go to Solution.
Hi!
CONTAINSSTRING() is probably a better function for this. I'm unsure if you want to use AND or OR as your operators for the required and forbidden words, so you would have to adjust accordingly, but something like this (also adjust table and columns names to your model):
AND in both cases:
Basal + Rapid =
CALCULATE(COUNT('Table'[Words]),
AND(CONTAINSSTRING('Table'[Words],"Basal"),CONTAINSSTRING('Table'[Words],"Rapid")) &&
NOT AND(CONTAINSSTRING('Table'[Words],"Premix"),CONTAINSSTRING('Table'[Words],"GLP"))
)
OR in both cases:
Basal + Rapid =
CALCULATE(COUNT('Table'[Words]),
OR(CONTAINSSTRING('Table'[Words],"Basal"),CONTAINSSTRING('Table'[Words],"Rapid")) &&
NOT OR(CONTAINSSTRING('Table'[Words],"Premix"),CONTAINSSTRING('Table'[Words],"GLP"))
)
Hope this helps!
I used your formula and changed it a bit using the OR and AND statements.
So my twicked formula count the rows that contain 'Basal' or 'Rapid' texts AND do not contain the text 'Premix' or 'GLP'
Basal +Rapid =
CALCULATE (
COUNT ( PRF[INTNR] ),
FILTER (
ALL ( PRF ),
(
SEARCH ( "Basal", PRF[Q15],, BLANK () ) > 0
|| SEARCH ( "Rapid", PRF[Q15],, BLANK () ) > 0
)
&& (
SEARCH ( "Premix", PRF[Q15],, BLANK () ) = 0
|| SEARCH ( "GLP", PRF[Q15],, BLANK () ) = 0
)
)
)
/ CALCULATE ( COUNT ( PRF[INTNR] ) )
Hi!
CONTAINSSTRING() is probably a better function for this. I'm unsure if you want to use AND or OR as your operators for the required and forbidden words, so you would have to adjust accordingly, but something like this (also adjust table and columns names to your model):
AND in both cases:
Basal + Rapid =
CALCULATE(COUNT('Table'[Words]),
AND(CONTAINSSTRING('Table'[Words],"Basal"),CONTAINSSTRING('Table'[Words],"Rapid")) &&
NOT AND(CONTAINSSTRING('Table'[Words],"Premix"),CONTAINSSTRING('Table'[Words],"GLP"))
)
OR in both cases:
Basal + Rapid =
CALCULATE(COUNT('Table'[Words]),
OR(CONTAINSSTRING('Table'[Words],"Basal"),CONTAINSSTRING('Table'[Words],"Rapid")) &&
NOT OR(CONTAINSSTRING('Table'[Words],"Premix"),CONTAINSSTRING('Table'[Words],"GLP"))
)
Hope this helps!
User | Count |
---|---|
74 | |
71 | |
42 | |
31 | |
28 |
User | Count |
---|---|
99 | |
93 | |
50 | |
49 | |
46 |