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
Anonymous
Not applicable

Count id by lf using dax

Dear Friends,

 

i have table1(name,Bank) and contains multiple bank id(by line break(lf)) to indivdiual user as show in table:

line break.JPG

 i need to count total bank id, for example, total bank id=11, and for Name8=3 and so on.

i did by power query using split by row(lf) and its working fine

but how can i get by using DAX ??

 

thanks

Jia

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Dear All

 

i solved myself the above problem, by:

 

len(bank id)-len(substitute(bank id,unichar(10),""))+1

 

Thanks

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Dear All

 

i solved myself the above problem, by:

 

len(bank id)-len(substitute(bank id,unichar(10),""))+1

 

Thanks

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

If your ids in one name is splicated by delimiters that occupy one character like space, you can try this code to count the bank id.

My sample:

RicoZhou_0-1655876695661.png

Measure:

Count Bank id = 
VAR _ADDLEN = ADDCOLUMNS('Table',"Length",LEN('Table'[Bank id]))
VAR _ADDCOUNT = ADDCOLUMNS(_ADDLEN,"Count ID", VAR _MINLEN = 7 VAR _MOD = MOD([Length],_MINLEN) RETURN _MOD + 1)
RETURN
SUMX(_ADDCOUNT,[Count ID])

Result is as below.

RicoZhou_1-1655876716458.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Anonymous
Not applicable

Dear 

 

i want to by direct Dax, not by Power Query because i have multiple data source and dont want to more complex

 

Here , total bank id is 11 because some name contains multiple bankd id by line break in bank id column.

We want to help.

The answer I provided is in DAX!

However, you will need an input table with populated columns on each row. You will need to do that in power query with fill.

 

Please share elexample input data as a table not a screen shot. So we can import the data and build a solution.

 

Also provide example desired output and description.

 

Dont share private data.

speedramps
Super User
Super User

In power query use the Fill option to populate the Name on every row.

 
Create these Dax measures
 
Banks = COUNTDISTINCT(tablename[Bank])
 
Name8 banks = 
CALCULATE(
[Banks],
tanlename[Name] = 'Nanes8")
 
All banks =
CALCULATE([Banks],ALL())
 
Create a table visual with
Name, Banks, Name8 banks, All banks
 
Notice how the Calculate command overrides the row context. The Name8 banks is the same value for every row !!
 
Hope you understand?
 
Please click thumbs up and accept as solution.
 
 
 
 
 
 

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.