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
B00m3r
Frequent Visitor

distinct values letters equal to 2 digit country code

I have a table similar to the below. I have 20,0000 assets from around the world prefixed with country code 2 digits follwed by other reference letters & numbers that indicate city, floor,room etc, each asset name is different, the only consistency is the 2 digit prefix for country. so for example I may have 5,000 with au-XXX, 3,000 with us-XXX and so on. My question is how do I count by first 2 digits only for each 2 digit country?

I have no idea where to start.

Table-1.PNG

1 ACCEPTED SOLUTION

Hi @B00m3r,

For example, I create a sample table only including [Assert Name] column, then create a calculated column as @Greg_Deckler posted.

sample tablesample tablecreate a calculated columncreate a calculated column
If you want to get how many asset name group by first 2 digit country code. Just select the calculated column and measure(count of assert name as row level), you will get expected result as follows.

3.png

Best Regards,
Angelia

View solution in original post

4 REPLIES 4
v-huizhn-msft
Employee
Employee

Hi @B00m3r,

Create a calculated column to get first two digits as @Greg_Deckler posted, then count values based on the new calculated column. Please feel free to ask if you have other issue.

Best Regards,
Angelia

Can you give me an example of the dax count values based on what you are suggesting here please?

Hi @B00m3r,

For example, I create a sample table only including [Assert Name] column, then create a calculated column as @Greg_Deckler posted.

sample tablesample tablecreate a calculated columncreate a calculated column
If you want to get how many asset name group by first 2 digit country code. Just select the calculated column and measure(count of assert name as row level), you will get expected result as follows.

3.png

Best Regards,
Angelia

Greg_Deckler
Super User
Super User

Well, the simplest way would be to create a new calculated column with a formula like:

 

FirstTwo = LEFT([Asset Name],2)

Then the problem is trivial.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors