Forum Discussion
shei7141
Helper III
6 years agoDax new table with multiple columns
Hi,
I have a table which has
Items, Yr2001, Yr2002, Yr2003....Yr2046
How can I create a new table which can return the following
Items (<<only unique values), Yrs, Value
x, 2001, 5
x, 2002,15
.
.
y,2046,1
y, 2001, 5
y, 2002,15
.
.
y,2046,1
Thanks in advance
A
- Anonymous6 years ago
I don't know how to programatically find out how many columns are there in your "calculated table", but if it is a fixed number of columns and you want to convert the same to the "Target" format, You could try this although, it is a bad example, and I feel, if you post the source table, instead of the calculated table, we can try out something.
Target = VAR T1 = ADDCOLUMNS( ALL('OriginalData'[Item],'OriginalData'[Year2001]), "Year",2001) VAR T2 = ADDCOLUMNS( ALL('OriginalData'[Item],'OriginalData'[Year2002]), "Year",2002) VAR T3 = ADDCOLUMNS( ALL('OriginalData'[Item],'OriginalData'[Year2003]), "Year",2003) RETURN UNION(T1,T2,T3)