cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
a10703
Frequent Visitor

Count comma in same cell

Hi guys,

I have one collumn with location

My collumn:

LOCATION
PORTUGAL
SPAIN
SPAIN
PORTUGAL
SPAIN
SPAIN
SPAIN
PORTUGAL
SPAIN
ITALY
ITALY
FRANCE
FRANCE


My measure to calculate the number of countries

MEASURELOCATION= calculate(counta('Table1'[Coluna1]),Filter(Table1,Table1[LOCATION]="SPAIN"))
 
The result is: 6
If i have the country and city in same cell it's possible to count?
 
tABLE LIKE:
LOCATION
PORTUGAL,LISBON
SPAIN,MADRID
SPAIN,BARCELONA
PORTUGAL,LISBON
SPAIN,SEVILHA
SPAIN,MADRID
SPAIN,BARCELONA
PORTUGAL,LISBON
SPAIN,BARCELONA
ITALY,ROMA
ITALY,ROMA
FRANCE,PARIS
FRANCE,PARIS

 

It's possible to count example: quantity of MADRID ?

MEASURELOCATION= calculate(counta('Table1'[Coluna1]),Filter(Table1,Table1[LOCATION]="MADRID"))

 Best regards,
 
 
 
1 ACCEPTED SOLUTION
rohit_singh
Super User
Super User

Hi @a10703,

The simplest way of doing it is to simply add the location column to the table and change the aggregation to "Count". This will give you a count of each city. 

 

rohit_singh_0-1654186413397.png

However, if your requirement is to specifically create measures, you can create one like below :
 

rohit_singh_1-1654186568720.png

Madrid Count =

COUNTROWS(
FILTER(
Locations,
CONTAINSSTRING(Locations[LOCATION], "MADRID")
)
)

You can modify this measure as per your requirement. Currently it is specific for Madrid but you can have a single measure to compute counts of each location as well.

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

View solution in original post

3 REPLIES 3
v-kkf-msft
Community Support
Community Support

Hi @a10703 ,

 

Please try the measure.

 

MEASURELOCATION = 
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER ( Table1, SEARCH ( "MADRID", Table1[LOCATION], 1, BLANK () ) > 0 )
)

vkkfmsft_0-1654666148481.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hey @v-kkf-msft ,

I need to count only by line not to all example 

In this case i need measure for madrid and other for spain because in the same cell i can have more than 1: example: SPAIN,MADRID,BARCELONA,MADRID 

a10703_0-1656954539575.png

Best regards and thanks for help

 

 

rohit_singh
Super User
Super User

Hi @a10703,

The simplest way of doing it is to simply add the location column to the table and change the aggregation to "Count". This will give you a count of each city. 

 

rohit_singh_0-1654186413397.png

However, if your requirement is to specifically create measures, you can create one like below :
 

rohit_singh_1-1654186568720.png

Madrid Count =

COUNTROWS(
FILTER(
Locations,
CONTAINSSTRING(Locations[LOCATION], "MADRID")
)
)

You can modify this measure as per your requirement. Currently it is specific for Madrid but you can have a single measure to compute counts of each location as well.

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.