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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
damit23183
Microsoft Employee
Microsoft Employee

Multirow into Single Row for Multiple Column

Hi,

 

I am trying to convert multirow into single row using DAX formula, but not getting expected result becuase there is comma i am getting everywhere at begining of value. Please see below for more explanation;

 

This is source table,

 

Table.JPG

 

 

 

 

So far i was able to get below result which is correct as expected for one of the dashboard;

 

Table.JPG

 

 

However, i would like to keep above table, and in addition i would like to achieve the result as you can see below;

Table.JPG

 

But, i am getting result like below;

Table.JPG

 

So far, i got the value as expected but if you see red highlighted in screen shot above, there is comma "," before the value which is everywhere. Also, if there is no BASIS for any caseID, comma is still coming there.

 

This is formula i have used to get expected result;

 

Formula :  

 

Basis String =
 
SWITCH(TRUE(), NOT(ISBLANK([Basis])),

CALCULATE(
CONCATENATEX (Claims, [Basis],", ", [caseID]) ,
FILTER ( 'Claims', 'Claims'[CaseID] = EARLIER ( 'Claims'[CaseID] )
)), BLANK()
)

 

I am using Filter on CASEID because if i dont use it then it gave the duplicates of BASIS in same row just like below; 

 

Table.JPG

 

 

 

 

Any help would be appreciated!

 

Thanks

1 ACCEPTED SOLUTION

hi  @damit23183 

Just add a filter to remove blank as below:

SWITCH(TRUE(), NOT(ISBLANK([Basis])),

CALCULATE(
CONCATENATEX ('Table', [Basis],", ", [caseID]) ,
FILTER ( 'Table', 'Table'[CaseID] = EARLIER ( 'Table'[CaseID] )&&'Table'[Basis]<>BLANK()
)), BLANK()
)

 

 

By the way, I would suggest you use this formula to create a new table

New Table = SUMMARIZE(
        'Claims',
        [CaseID],
        "Title",CONCATENATEX(DISTINCT('Claims'[Title]),[Title],","),
        "Type",CONCATENATEX(DISTINCT('Claims'[Type]),[Type],","),
        "Basis",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Basis]),[Basis],","),FILTER('Claims','Claims'[Basis]<>BLANK()))
    )

or

New Table = SUMMARIZE(
        'Claims',
        [CaseID],
        "Title",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Title]),[Title],","),FILTER('Claims','Claims'[Basis]<>BLANK())),
        "Type",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Type]),[Type],","),FILTER('Claims','Claims'[Basis]<>BLANK())),
        "Basis",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Basis]),[Basis],","),FILTER('Claims','Claims'[Basis]<>BLANK()))
    )

 and here is sample pbix file, please try it.

 

 

Regards,

Lin

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

View solution in original post

10 REPLIES 10
DataZoe
Microsoft Employee
Microsoft Employee

@damit23183 you could try this:

 

     CALCULATE (
        CONCATENATEX ( VALUES ( Claims[Basis] ), Claims[Basis], ", " ),
        FILTER ( Claims, Claims[CaseID] = MIN ( Claims[CaseID] ) )
    )

 

Edit: I should add, that this is a measure, and then you would put it and the CaseID in a table or matrix!

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

HI,

 

Thanks for your response,

 

I tried your solution but same thing happend. 

 

Comma came in for some cases. 

 

It does look like some Blank cells available for specific Cases.

 

If i want to add some filter or remove blank in existing formula you gave me then,

 

How would i get rid of blank value for any cases in my scenario?

 

Thanks

I did this:

Table 2 = 
    SUMMARIZE(
        'Table',
        [CaseID],
        "Title",CONCATENATEX(DISTINCT('Table'[Title]),[Title],","),
        "Type",CONCATENATEX(DISTINCT('Table'[Type]),[Type],","),
        "Basis",CONCATENATEX(DISTINCT('Table'[Basis]),[Basis],",")
    )

See attached.

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@damit23183 maybe try this one:

 

    CALCULATE (
        CONCATENATEX (
            FILTER ( VALUES ( Claims[Basis] ), ISBLANK ( Claims[Basis] ) = FALSE () ),
            Claims[Basis],
            ", "
        ),
        FILTER ( Claims, Claims[CaseID] = MIN ( Claims[CaseID] ) )
    )

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Hi,

 

Still same result.

 

Looks like BLANK is the issue which must remove.

 

Thanks

hi  @damit23183 

Just add a filter to remove blank as below:

SWITCH(TRUE(), NOT(ISBLANK([Basis])),

CALCULATE(
CONCATENATEX ('Table', [Basis],", ", [caseID]) ,
FILTER ( 'Table', 'Table'[CaseID] = EARLIER ( 'Table'[CaseID] )&&'Table'[Basis]<>BLANK()
)), BLANK()
)

 

 

By the way, I would suggest you use this formula to create a new table

New Table = SUMMARIZE(
        'Claims',
        [CaseID],
        "Title",CONCATENATEX(DISTINCT('Claims'[Title]),[Title],","),
        "Type",CONCATENATEX(DISTINCT('Claims'[Type]),[Type],","),
        "Basis",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Basis]),[Basis],","),FILTER('Claims','Claims'[Basis]<>BLANK()))
    )

or

New Table = SUMMARIZE(
        'Claims',
        [CaseID],
        "Title",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Title]),[Title],","),FILTER('Claims','Claims'[Basis]<>BLANK())),
        "Type",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Type]),[Type],","),FILTER('Claims','Claims'[Basis]<>BLANK())),
        "Basis",CALCULATE(CONCATENATEX(DISTINCT('Claims'[Basis]),[Basis],","),FILTER('Claims','Claims'[Basis]<>BLANK()))
    )

 and here is sample pbix file, please try it.

 

 

Regards,

Lin

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

Hi,

 

Thanks for your response.

 

Your solution is working perfectly by just adding && condition in SWITCH formula which did not even think of it.

 

Thank you so much. 

 

I can't create new table though because there other information needed from same table so it can become complext. Therefore, I was trying to get it work in same table.

 

Thanks again for your help.

@damit23183 I should probably make some fake data at this point, but one last try:

 

CALCULATE (
        CONCATENATEX (
            FILTER ( VALUES ( Claims[Basis] ), ISBLANK ( Claims[Basis] ) = FALSE () ),
            Claims[Basis],
            ", "
        ),
        FILTER ( Claims, Claims[CaseID] = MIN ( Claims[CaseID] ) && ISBLANK ( Claims[Basis] ) = FALSE () )
    )

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Hi,

 

Thanks for another suggestion.

 

Last sugggestion also gave me same result with comma ahead of the value. However, thanks a lot for all suggestion made by you as I got to learn something new too.

 

Thanks

AllisonKennedy
Super User
Super User

@damit23183 I cannot replicate your problem. When I try with your sample data, I have no comma. 

 

Does your full dataset contain some blanks for Basis? That might be what is causing the leading comma with no text before it. If so, you can use an IF or other option to check for blanks, or add a condition to the FILTER using && to check that Basis is not blank.

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.