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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Ozcoz
Frequent Visitor

Count occurrences within a field

I'm encountering a challenge with counting occurrences of specific values in a field. In a column named STRATEGY, I currently have the following DAX measure to count occurrences:

 
STRATEGY_measure = CALCULATE( COUNTROWS(MNES), FILTER( MNES, MNES[STRATEGY] IN { "Value 1", "Value 2", "Value 3", "Value 4", "Value 5", "Value 6" } ) )

 

The provided DAX measure functions, however the count seems to consider only the first instance in each field and doesn't include subsequent values separated by a delimiter ("/"). For example, if a row has values "Value 1 / Value 2," the measure only counts "Value 1" and not "Value 2."

 

I've tried separating the values by the delimiter, but then thats a different formula which I couldn't work out.  What's the best to approach so that I can count all the occurences of a value?

 

Thanks.

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Ozcoz,

 

One option is to split the column into rows using Power Query: Split Column --> By Delimiter --> Split into Rows.

 

DataInsights_0-1700752458370.png

You can simplify the measure as follows:

 

STRATEGY_measure =
CALCULATE (
    COUNTROWS ( MNES ),
    MNES[STRATEGY]
        IN { "Value 1", "Value 2", "Value 3", "Value 4", "Value 5", "Value 6" }
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@Ozcoz,

 

One option is to split the column into rows using Power Query: Split Column --> By Delimiter --> Split into Rows.

 

DataInsights_0-1700752458370.png

You can simplify the measure as follows:

 

STRATEGY_measure =
CALCULATE (
    COUNTROWS ( MNES ),
    MNES[STRATEGY]
        IN { "Value 1", "Value 2", "Value 3", "Value 4", "Value 5", "Value 6" }
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.