Forum Discussion
smpa01
Community Champion
4 years agoConstructing table in Dax from Variables
I am trying to figure out how can I end with a table from at least two variables
My code is following
Table =
VAR first = "a"
VAR second = "b"
VAR x= CROSSJOIN(DATATABLE("column1",STRING,{...
- 4 years ago
smpa01 Not sure if this is what you are looking for? You can do crossjoin these two variables and rename the column name, or use selectcolumns and then cross join
Table = VAR a = {"a","b","c"} VAR b = {"e", "f","g"} RETURN CROSSJOIN ( SELECTCOLUMNS ( a, "First", [Value] ), SELECTCOLUMNS ( b, "Second", [Value] ) )or you want row 1 of each table to join and then row 2 to row 2 and so on...
what is your end goal?
AlexisOlson
Super User
4 years agoIn addition to CROSSJOIN, you can also use GENERATE or GENERATEALL.
Table =
VAR a = { "a", "b", "c" }
VAR b = { "e", "f", "g" }
VAR aTbl = SELECTCOLUMNS ( a, "First", [Value] )
VAR bTbl = SELECTCOLUMNS ( b, "Second", [Value] )
RETURN
GENERATE ( aTbl, bTbl )