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
ihayes916
Frequent Visitor

If value is table, extract value(s) to csv, otherwise take value as is...

Greerings - 

I have a column that has both 'Table' and 'text' values. 

What I'd like to do is; 
If value type == table then, extract values to new column (myNewCustomColumn) as CSV.
else copy existing value to new column (myNewCustomColumn).

Can someone please help w/ this type of logic/formula?

Attached mockup of data for clarity.

 

Thanks!!!!

 

help.JPG 

1 ACCEPTED SOLUTION

Hi @ihayes916,

 

You can use below query to get expand values:

let
    Source = #table( type table [#"Component"=any], 
	{
		{"abc"},
                {"Cda"},
                {"AAA"},
		{#table({"Element"}, {{"esc"},{"Test"}})},
		{#table({"Element"}, {{"EAd"},{"BAA"}})}
	}),
    #"Added Custom" = Table.AddColumn(Source, "Expand", each if Value.Is([Component],type table) then Text.Combine([Component][Element],",") else [Component])
in
    #"Added Custom"

21.PNG

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @ihayes916,

 

Can you please share some sample data or pbix file for test?

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hello @v-shex-msft!

 

Thanks for the reply.  Unfortunatly, I can't share the data and I've not found a way to recreate a small sample data set.  

I've attached a more refined version (screen shot) of my request.

 

Column1 (Component) is my source data.

Column2 (ExtractedValues) is the custom column that I am hoping to be able to create.  I've mocked up the result I'd like to see for each of the 3 scenarios.

 

Again, thanks for any help you might be able to provide!

 

 

help2.JPG

Hi @ihayes916,

 

You can use below query to get expand values:

let
    Source = #table( type table [#"Component"=any], 
	{
		{"abc"},
                {"Cda"},
                {"AAA"},
		{#table({"Element"}, {{"esc"},{"Test"}})},
		{#table({"Element"}, {{"EAd"},{"BAA"}})}
	}),
    #"Added Custom" = Table.AddColumn(Source, "Expand", each if Value.Is([Component],type table) then Text.Combine([Component][Element],",") else [Component])
in
    #"Added Custom"

21.PNG

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you so much!!!!!  I came to a similar solution (albeit w/ one extra step) but I like yours better!!!

 

Truly appreciate it! 

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.