Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
garythomannCoGC
Impactful Individual
Impactful Individual

how to add a literal row to a dax table

 

 

 

-- create two tables and join together
DEFINE
    TABLE AllTable     = DATATABLE ( "Column Name", STRING, {{"All"}} )
    TABLE SummaryTable = DATATABLE ( "Column Name", STRING, {{"Yes"}} )

    --TABLE UnionTable = UNION ( AllTable, SummaryTable )    -- 1
    TABLE UnionTable = UNION ( row ("Column Name", "All" ), SummaryTable )  -- 2
EVALUATE
    UnionTable
    --SummaryTable 
    --AllTable

 

 

 

Trying to sandwich a literal table with an existing table.  ie add a row to a single column table.

In dax studio getting the error  "Failed to resolve name 'SummaryTable'.  It is not a valid table, variable or function name".

 

Yet  SummaryTable  as the return value will give the "Yes" result without error.   --2 is another attempt and giving the same error result.

 

What am I missunderstanding with dax here?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@garythomannCoGC , Try like

 

DEFINE
    var AllTable     = DATATABLE ( "Column Name", STRING, {{"All"}} )
    var SummaryTable = DATATABLE ( "Column Name", STRING, {{"Yes"}} )

    --var UnionTable = UNION ( AllTable, SummaryTable )    -- 1
     var UnionTable = UNION ( row ("Column Name", "All" ), SummaryTable )  -- 2
EVALUATE
    UnionTable
    --SummaryTable 
    --AllTable

View solution in original post

2 REPLIES 2
garythomannCoGC
Impactful Individual
Impactful Individual

@amitchandak Thank you for your reply.  Works for both UnionTable scenarios.  Doh, I had started with VAR's then got the error then switched to TABLE usage thinking the code needed tightening  ie dealing only with tables.

Just had a play and when the UnionTable  line is declared as TABLE we get the error.  

 

Oh boy that does not make sense!  Why does the declaration of UnionTable need to be VAR and bombs with TABLE!?

And which would you choose for the initial declarations?  VAR just seems too loose 🙂

 

Lol and which would you pick and why for the UNION statement?  I'm thinking  --1  as this looks more straightforward (maybe more SQL-ish :)) 

amitchandak
Super User
Super User

@garythomannCoGC , Try like

 

DEFINE
    var AllTable     = DATATABLE ( "Column Name", STRING, {{"All"}} )
    var SummaryTable = DATATABLE ( "Column Name", STRING, {{"Yes"}} )

    --var UnionTable = UNION ( AllTable, SummaryTable )    -- 1
     var UnionTable = UNION ( row ("Column Name", "All" ), SummaryTable )  -- 2
EVALUATE
    UnionTable
    --SummaryTable 
    --AllTable

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors