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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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