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
KWelsh8144
Helper II
Helper II

Count If conditions

I'm trying to get a count to be represented in a card...

 

My data looks like this:

 

displaynameType
test name 1A
test name 1B
test name 1B
test name 1B
test name 1B
test name 1C
test name 1C
test name 1C
test name 2B
test name 2B
test name 2B
test name 2B
test name 2C
test name 2D
test name 2D

 

I want to get a count of the number of distinct displaynames where type = b and b is listed more than 3 times. I can't figure out the dax I need to get this..

 

Can anyone assist?

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @KWelsh8144 ,

 

Please try this measure:

Measure = 
var _t=SUMMARIZE('Table',[displayname],[Type],"Count",COUNTROWS('Table'))
return COUNTROWS(FILTER(_t,[Type]="B" && [Count]>3))

Result:

vcgaomsft_0-1667444872550.png

The PBIX file is attached for reference.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

3 REPLIES 3
v-cgao-msft
Community Support
Community Support

Hi @KWelsh8144 ,

 

Please try this measure:

Measure = 
var _t=SUMMARIZE('Table',[displayname],[Type],"Count",COUNTROWS('Table'))
return COUNTROWS(FILTER(_t,[Type]="B" && [Count]>3))

Result:

vcgaomsft_0-1667444872550.png

The PBIX file is attached for reference.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

rsbin
Super User
Super User

@KWelsh8144 ,

I would handle your question like this.  First create a calculated column to Count the B's per DisplayName:

CountBs = 
Var _DisplayName = MAX([displayname])
Var _Result = CALCULATE( COUNTA( [Type] ), FILTER(TestName, TestName[displayname] = _DisplayName && [Type] = "B" ))
RETURN
_Result

displaynameTypeCountBs

test name 1 A 4
test name 1 B 4
test name 1 B 4
test name 1 B 4
test name 1 B 4
test name 1 C 4
test name 1 C 4
test name 1 C 4
test name 2 B 4
test name 2 B 4
test name 2 B 4
test name 2 B 4
test name 2 C 4
test name 2 D 4
test name 2 D 4

Then create a Measure:

DisplayName_Count = CALCULATE( DISTINCTCOUNT( TestName[displayname] ),
                          FILTER( TestName, TestName[CountBs] >= 3 ))

rsbin_0-1664995908684.png

If you really wanted, this could all be combined in one step using Variables, but this way shows you explicitly what the calculations are doing.

Regards,

Thanks for the response - it doesn't seem to be working; the first calculated column reads them all as '4', regardless of how many 'b's are assigned to each name. Does this have anything to do with reading the displayname as the max? 

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.