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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GSynchro
Regular Visitor

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 2
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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