Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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,{{first}}),DATATABLE("column2",STRING,{{second}}))
VAR y = CROSSjoin({first},{second})
RETURN _y
I want to end up with a table containg two columns with a and b that is quivalent of what the following can do
DATATABLE("first",string,"second",string,{{"a","b"}})
I can't get to where I need to as it is generating the following error in both instances
what is the workaround here?
Solved! Go to Solution.
@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?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
In 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 )
@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?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k It worked mate !!! thanks a lot.
It was a very small part of a very useful huge calcuation and pieces are aligining.
Thanks again.
@AlexisOlson @parry2k @CNENFRNL @OwenAuger
Need to bump this one up.
@az38 Wow !!! very elegant !!! Thanks
I do have a follow up Q
If
VAR a = {"a","b","c"}
VAR b = {"e", "f","g"}
How can I still achieve the end goal without manually writing a ROW reference cause VAR a and VAR b are getting dynamically generated
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.