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
Anonymous
Not applicable

Getting data from different columns and multiple rows into a single row (and filtering off some)

Hello,

 

I've been looking through the forum and despite I've found very good ideas, all of them ended in unsucessful results.

 

I've got the table structure below. Note that Value column sometimes contains same or similar values as text...

 

MainIDFieldTextDateTimeNumberValue
1NameJohn  John
1CountryUS   
1Date 01.01.2018  
1Sales  15000 
1ProductXenon1  Xenon 1
2NameMark   
2CountryUK   
2Date 01.04.2018  
2Sales  2000 
2ProductXenon 1  Xenon 1
2CommentsOn vacation   
3NameAndy  Andrew
3CountryCanada   
3Date 01.03.2018  
3Sales  3000 
3ProductXenon2  Xenon 2

 

And obviously I want to get all in a single row, like this:

 

MainIDNameCountryDateSalesProductComments
1JohnUS01.01.201815000Xenon1null
2MarkUK01.04.20182000Xenon1On Vacation
3AndrewCanada01.03.20183000Xenon 2null

 

I've managed to put every value in just one column (converting datetime and number to text. No problem, will change them later) by using a modification of:

= Text.Combine(List.Select({[Col1],[Col2],[Col3],[Col4]}, each _<> "" and _ <> null)," & ")

 I did one run for value, datetime and number, and then another one for text. This got me quite close to what I want,

 

MainIDLabelValue
1NameJohn
1CountryUS
1Country1
1Date01.01.2018
1Sales1500
1ProductXenon1
2NameMark
2CountryUK
2Date01.04.2018
2Sales2000
2ProductXenon 1
2CommentsOn vacation
3NameAndy
3CountryCanada
3Date01.03.2018
3Sales3000
3ProductXenon2

 

But still... The 'Label' rows are duplicated (I just forced the example with 'Country') what produces errors when pivoting the columns. I just want to keep the values that begin with a number, let's say '1'.

 

Sorry for the long post, but I wanted to detailed the issue as much as possible. I'll really appreciate any help. Thanks!

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

As we can see from the sample data, every attribute only has one value except the "Name". The workaround or solution could be as follows. You can check out the demo here.

1. Add a new column with the formula below.

if not ([Value] is null) 
    then [Value]  
else if not ([Text] is null) 
    then [Text] 
else if not ([DateTime] is null) 
    then [DateTime] 
else if not ([Number] is null) 
    then [Number] 
else "CHECK AGAIN"

2. Keep columns "MainID", "Field", "Custom" only and delete other columns.

3. Povit the columns "Field" and "Custom".

Getting_data_from_different_columns_and_multiple_rows_into_a_single_row

 

 

Best Regards,

Dale

Community Support Team _ Dale
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

1 REPLY 1
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

As we can see from the sample data, every attribute only has one value except the "Name". The workaround or solution could be as follows. You can check out the demo here.

1. Add a new column with the formula below.

if not ([Value] is null) 
    then [Value]  
else if not ([Text] is null) 
    then [Text] 
else if not ([DateTime] is null) 
    then [DateTime] 
else if not ([Number] is null) 
    then [Number] 
else "CHECK AGAIN"

2. Keep columns "MainID", "Field", "Custom" only and delete other columns.

3. Povit the columns "Field" and "Custom".

Getting_data_from_different_columns_and_multiple_rows_into_a_single_row

 

 

Best Regards,

Dale

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

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.