简体   繁体   中英

SQL & Power Bi/Query - Turn a column array into columns

sql表

here's some fun. One of our tables has a column, 'Reference Type', which the value is a Variable and the variable's value is in column 'Reference Value'. The key is 'XMLID' and the rest of the columns are associated to that variable.

The problem is we need to supply a value to one Reverence Type in order to get that key, in order to pull all the other variables associated to that key.

I can only query the table, I do not have SQL write privileges, and so am importing the data into Power Bi/Query for manipulation

Is there a way to pivot the Reference Type variables out while keeping all of the associated columns?

The transform you need is called Pivot , eg:

= Table.Pivot(Source, List.Distinct(Source[ReferenceType]), "ReferenceType", "ReferenceValue")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM