cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Swinden
Frequent Visitor

Combine Columns in a Measure

I will start by saying we are using an Azure model that i don't have access to change the model to add a calculated column, so i am hoping to figure out a way to do this using a measure as I can create new measures in desktop before publishing to my user group.

 

I have two columns, one called Producer, the other called Package Type.  I want to use a measure (if possible) to combine these two columns in one text string.  example below (from excel) where i have combined Producer and Package with a space in between.

 

Any ideas how to solve?

 

Swinden_0-1629242517576.png

 

1 ACCEPTED SOLUTION
Eyelyn9
Community Support
Community Support

Hi @Swinden ,

 

According to your description, it seems that you want to display all combined producer and package values in a Card visual based on the selections selected in the slicer, right?

 

If so , please try the following formula to create a measure:

Measure = 
VAR _t =
    SUMMARIZE ( ALLSELECTED ( 'Table' ), [PACKAGE], [PROCUCER] )
RETURN
    CONCATENATEX ( _t, [PROCUCER] & " " & [PACKAGE], "  ,  ", [PROCUCER], ASC )

 

Here is the final output:

combine all selected values.gif

 

Best Regards,
Eyelyn Qin
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
Eyelyn9
Community Support
Community Support

Hi @Swinden ,

 

According to your description, it seems that you want to display all combined producer and package values in a Card visual based on the selections selected in the slicer, right?

 

If so , please try the following formula to create a measure:

Measure = 
VAR _t =
    SUMMARIZE ( ALLSELECTED ( 'Table' ), [PACKAGE], [PROCUCER] )
RETURN
    CONCATENATEX ( _t, [PROCUCER] & " " & [PACKAGE], "  ,  ", [PROCUCER], ASC )

 

Here is the final output:

combine all selected values.gif

 

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

parry2k
Super User
Super User

@Swinden no sure what you mean it returns one value, you have to put other two columns in the visual, and this measure then it will work, otherwise there is no solution for this except adding this as a column in the base model.

 

Think about, measures are aggregation and if you are not showing at a row-level data, the measure will not show you each value. Try to understand the basics of how it works, and you will get why you are getting one value. Hope it helps.






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.





Ashish_Mathur
Super User
Super User

Hi,

Drag Producer and Package to a Table visual and write this measure

=min(Data[Producer])&" "&min(Data[Package])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you Ashish.  This sort of works, but only returns 1 value, I want it to return all values which will be potentially hundreds of records depending on how i apply slicers.  Any ideas?

Hi,

I do not understand what you want.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
VahidDM
Super User
Super User

Hi @Swinden 

 

Try this measure:

CONCATENATE =
CONCATENATE (
    FIRSTNONBLANK ( 'Table'[Producer], "" ),
    " " & FIRSTNONBLANK ( 'Table'[Package], "" )
)

the output will be as follow:

 

VahidDM_1-1629246151986.png

 

Did I answer your question? Mark my post as a solution!

Appreciate your Kudos VahidDM_0-1629246094483.png !!

Swinden
Frequent Visitor

Thank you Vahid.  This also sort of works, but only returns 1 value, I want it to return all values which will be potentially hundreds of records depending on how i apply slicers.  Any ideas?

parry2k
Super User
Super User

@Swinden your measure will be:

 

 

Concatenate = 
COMBINEVALUES(" ", MAX ( Table[Column1] ), MAX ( Table2[Column2] ) )

 

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.






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.





Swinden
Frequent Visitor

Thank you Parry2k.  This works the same as the above two solutions, but only returns 1 value, I want it to return all values which will be potentially hundreds of records depending on how i apply slicers.  Any ideas?

@Swinden 

 

Can you take a snapshot of your Power BI report and ideal output [or develop it on excel] and share it with us?

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors