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
CarlsBerg999
Helper V
Helper V

Counting values and concatenating them

Hi, 
 
I'm using a simple measure in my matrix:

Programs = CONCATENATEX
('Project Task ','Project Task'[Program], UNICHAR(10))
 
The result in the matrix is presented below: 

WeekCategory 1Category 2
WK1Program A
Program A
Program B
Program B
Program B
Program B
WK2Program A
Program A
Program B
Program B
 

 

The problem is the repeatead values in same cell. I don't want DISTINCT values either, because i need to know that there are 2 x of Program A in WK1 / Category 1. What i need is it to show "Program A x 2" 

 

Goal: 

 

WeekCategory 1Category 2
WK1Program A x 2
Program B
Program B x 3
WK2Program A x 2
Program B x 2
 

 

 

How do i do this in dax? 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@CarlsBerg999 Maybe:

 

Programs =
  VAR __Table = SUMMARIZE('Project Task','Project Task'[Program],"__Count",COUNTROWS('Project Task')
RETURN
  CONCATENATEX(
    __Table,
    IF([__Count]>1,[Program] & " x" & [__Count],[Program]),
    UNICHAR(10)
  )

 


@ 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...

View solution in original post

2 REPLIES 2
Thejeswar
Resident Rockstar
Resident Rockstar

Hi @CarlsBerg999 ,

I have modified the DAX that @Greg_Deckler suggested to avoid issues because of NULLs (Blanks).

The Below are the two measures

mymeasureA = 
VAR _count = SUMMARIZE(Table_my, Table_my[Week], Table_my[Category 1], "_count", IF(countrows(Table_my) - COUNTBLANK(Table_my[Category 1]) = 0, BLANK(), countrows(Table_my) - COUNTBLANK(Table_my[Category 1])))
return
CONCATENATEX(_count, IF([_count] > 1, [Category 1] & " x " & [_count], [Category 1]), " 
")
mymeasureB = 
VAR _count = SUMMARIZE(Table_my, Table_my[Week], Table_my[Category 2], "_count", IF(countrows(Table_my) - COUNTBLANK(Table_my[Category 2]) = 0, BLANK(), countrows(Table_my) - COUNTBLANK(Table_my[Category 2])))
return
CONCATENATEX(_count, IF([_count] > 1, [Category 2] & " x " & [_count], [Category 2]), "
")

 

The Output below

Thejeswar_0-1641996933799.png

 

Greg_Deckler
Super User
Super User

@CarlsBerg999 Maybe:

 

Programs =
  VAR __Table = SUMMARIZE('Project Task','Project Task'[Program],"__Count",COUNTROWS('Project Task')
RETURN
  CONCATENATEX(
    __Table,
    IF([__Count]>1,[Program] & " x" & [__Count],[Program]),
    UNICHAR(10)
  )

 


@ 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.