Forum Discussion

GSynchro's avatar
GSynchro
Regular Visitor
7 years ago

Pulling table names/if statement

Hello, so I have 4 tables: ABC, DEF, GHI, and XYZ. All tables have the same column names, but with different values. I wanted to grab the minimum of a column across ABC, DEF, and GHI. So in XYZ, I created the column

min = CALCULATE(MINX(UNION(ABC, DEF, GHI),[columnName]))

 

That worked great, but now I would like to know where that minimum came from. Is there a way to do an if statement that creates a column minTable to calculate the following process by row:

if min=ABC[columnName]

then minTable = ABC

elseif min=DEF[columnName]

then minTable = DEF

else minTable = GHI

???

 

I haven't had much luck with this, so even if your suggestion is that I set the original data up in a different way, I'll take any suggestions! Thanks!

2 Replies

  • GSynchro's avatar
    GSynchro
    Regular Visitor

    Another option I tried that didn't seem to work was adding a column on each table with the table name, then appending tables ABC, GHI, and DEF, then placing [columnName] and [tableName] in a table and having [columnName] to show the minimum. I thought maybe if I sorted [columnName] from smallest to greatest in the table, that First [tableName] would return the one associated with the minimum, but that didn't work either.

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI GSynchro ,

    AFAIK, current if statement not support return table as expression result.(even if you used it in calculated table)
    In addition, power bi also not support to create dynamic calculated column/table based on filter.
    So I think you can't use if statement or filter to create a dynamic calculated table.

    Regards,

    Xiaoxin Sheng