Forum Discussion
MiKeZZa
Post Patron
9 years agoDuplicating some data by adding a table and union them
Hi all, I want to duplicate/manipulate a imported table. The table has many columns, but to keep it simple lets say 3 columns... yearmonth value origin 201612 10 real d...
- 9 years ago
Hi MiKeZZa,
How close is this? Create a calculated table using the following.....
New DAX table = VAR Tb1 = FILTER('Table','Table'[origin]="Real data") VAR MaxDate = CALCULATE(MAX('Table'[yearmonth]),'Table'[origin]="Real data") VAR Tb2 = SELECTCOLUMNS( FILTER('Table','Table'[origin]="Real data" && 'Table'[yearmonth] =MaxDate), "yearmonth" , [yearmonth] , "value" , [value], "origin" , "forecast") Return UNION(Tb1,Tb2)
Phil_Seamark
Microsoft Employee
9 years agoHi MiKeZZa,
How close is this? Create a calculated table using the following.....
New DAX table =
VAR Tb1 = FILTER('Table','Table'[origin]="Real data")
VAR MaxDate = CALCULATE(MAX('Table'[yearmonth]),'Table'[origin]="Real data")
VAR Tb2 = SELECTCOLUMNS(
FILTER('Table','Table'[origin]="Real data" && 'Table'[yearmonth] =MaxDate),
"yearmonth" , [yearmonth] ,
"value" , [value],
"origin" , "forecast")
Return UNION(Tb1,Tb2)MiKeZZa
Post Patron
9 years agoYes this is great!!! Simple and effective!
I've had some issues with it; it stopped working my Power BI Desktop a few times, but after stopping with pasting the code into it and making it myself it worked great.
I've changed the last rule of code to this:
Return union('Table',tb2)because of that I want the whole dataset, with the duplicated month.