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
rossnruthie
Resolver I
Resolver I

Help Concatenatex with Blanks Giving Unexpected Results (Sample Included)

Link to sample report pbix: Concatenate With Blanks

 

I have a report where I am trying to use the Concatenatex function to create a list of features associated with a vehicles catalogue.  My model looks like this:

image.png

image.png

As you can see for a given OEM->Vehicle->Catalogue there can be many features associated with it.  My initial goal was to display all features as a concatenated list of values in a single row rather than duplicating all rows per feature.  So I created a measure:

 

 

FeatureList = 
			CONCATENATEX(
				VALUES('Features'[FeatureDescription]),
				'Features'[FeatureDescription],
				", ",
				'Features'[FeatureDescription],
				ASC
			)

While this does concatenate all values into a single row, it has the unintended side effect of hiding any catalogue that doesn't have any features. 

image.png

So I created a second measure using the original FeatureList as a base.

 

FeatureListWithBlanks = IF(ISBLANK([FeatureList]),"N/A",[FeatureList])

And here is where it comes of the rails.  The result of this measure appears to be the cartesian product of all 4 tables with a bunch of repeating values.  So is there a way in DAX i can do this properly so that I display the brand, vehicle, catalogue and it's concatenated list of values even if blank?

 

I've also tried:

  1. Right click a value in visual and select show items with no data
    1. My actual model is massive and doing this blows out the memory.
  2. Add a dummy measure Count('Catalogue'[CatalogueKey]) as a column and then "hide" the column.  This displays all the blanks and you can't see the dummy column since i collapse it but when the user exports the data this column is included and is not an ideal solution.

Result of FeatureListWithBlanks:

image.png

 

1 ACCEPTED SOLUTION

@parry2k thanks for the suggestion.

 

Unfortunately in my situation there are quite a few of these fields and due to the size of the underlying model we would prefer to keep them as measures rather than storing all of them in memory as a calculated column.

 

The good news though is that I've modified my measure so that it works and doesn't blow out the memory.  I basically nest my original measure inside an additional IF() that checks for the existence of a record in the Catalogue table.  If a catalogue record exists then I want to display something (either "N/A" or the features if they exist) and if a catalogue record doesn't exist then keep it BLANK.

 

I've changed the calculation to:

FeatureListWithBlanks = 
	IF(
            ISBLANK(MAX(Catalogue[CatalogueKey])),
            BLANK(),
            IF(
               ISBLANK([FeatureList]),
               "N/A",
               [FeatureList]
               )
           )

And this displays as I would expect.

image.png 

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@rossnruthie add it as a column

 

FeatureListAsCol = CALCULATE(
			CONCATENATEX(
					VALUES('Features'[FeatureDescription]),
				'Features'[FeatureDescription],
				", ",
				'Features'[FeatureDescription],
				ASC
			)
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k thanks for the suggestion.

 

Unfortunately in my situation there are quite a few of these fields and due to the size of the underlying model we would prefer to keep them as measures rather than storing all of them in memory as a calculated column.

 

The good news though is that I've modified my measure so that it works and doesn't blow out the memory.  I basically nest my original measure inside an additional IF() that checks for the existence of a record in the Catalogue table.  If a catalogue record exists then I want to display something (either "N/A" or the features if they exist) and if a catalogue record doesn't exist then keep it BLANK.

 

I've changed the calculation to:

FeatureListWithBlanks = 
	IF(
            ISBLANK(MAX(Catalogue[CatalogueKey])),
            BLANK(),
            IF(
               ISBLANK([FeatureList]),
               "N/A",
               [FeatureList]
               )
           )

And this displays as I would expect.

image.png 

@rossnruthie glad, it worked. Infact I do prefer  measure but was not sure about the model. It is good that you have working solution. Cheers



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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