Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi, I need to count
IF Unique ID has "Apples" AND "Oranges" then count only "Apples"
IF Unique ID has "Apples" AND any other catergory, count as 1
I assume this is some kind of Filter Calculate combination but I cannot figure it out
Thank you for your assistance!
Solved! Go to Solution.
@StoryofData you can write a measure like this
Measure =
VAR _left =
SELECTCOLUMNS (
FILTER ( ALL ( 'Table' ), 'Table'[UID] = MAX ( 'Table'[UID] ) ),
"cat", 'Table'[Category] & ""
)
VAR _filt =
CONTAINSROW ( _left, "apple" )
VAR __count =
IF (
_filt = TRUE (),
COUNTROWS (
FILTER ( VALUES ( 'Table'[Category] ), 'Table'[Category] <> "Orange" )
),
COUNTROWS ( 'Table' )
)
RETURN
__count
I wrote as
VAR _left
and not
VAR_left
try rhis
Column =
VAR _left =
SELECTCOLUMNS (
FILTER ( 'Table', 'Table'[UID] = EARLIER ( 'Table'[UID] ) ),
"cat", 'Table'[Category] & ""
)
VAR _filt =
CONTAINSROW ( _left, "apple" )
VAR __count =
IF (
_filt = TRUE (),
CALCULATE ( COUNTROWS ( FILTER ( 'Table', 'Table'[Category] <> "Orange" ) ) ),
CALCULATE ( COUNTROWS ( 'Table' ) )
)
RETURN
__count
@StoryofData you can write a measure like this
Measure =
VAR _left =
SELECTCOLUMNS (
FILTER ( ALL ( 'Table' ), 'Table'[UID] = MAX ( 'Table'[UID] ) ),
"cat", 'Table'[Category] & ""
)
VAR _filt =
CONTAINSROW ( _left, "apple" )
VAR __count =
IF (
_filt = TRUE (),
COUNTROWS (
FILTER ( VALUES ( 'Table'[Category] ), 'Table'[Category] <> "Orange" )
),
COUNTROWS ( 'Table' )
)
RETURN
__count
Is it possible to convert this result to a new column rather than a count?
If I am asking too much, I apologize
@StoryofData what is the desired output
New Column with a count of 1 or 0 like I have in my picture above
I realize that straight up count will not let me do futher analysis, I need an actual column that will show 1 or 0 depending on category
try rhis
Column =
VAR _left =
SELECTCOLUMNS (
FILTER ( 'Table', 'Table'[UID] = EARLIER ( 'Table'[UID] ) ),
"cat", 'Table'[Category] & ""
)
VAR _filt =
CONTAINSROW ( _left, "apple" )
VAR __count =
IF (
_filt = TRUE (),
CALCULATE ( COUNTROWS ( FILTER ( 'Table', 'Table'[Category] <> "Orange" ) ) ),
CALCULATE ( COUNTROWS ( 'Table' ) )
)
RETURN
__count
THANK YOU SO MUCH!
thank you so much for taking the time, for some reason, VAR_left is underlining as an error...
I wrote as
VAR _left
and not
VAR_left
Pardon, I see my error, this works! Thank you!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.