cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hev-fj
Frequent Visitor

Gallery: Check if the field exists in the data source using ThisItem.

Is it possible to check if a field is exist in the data source of the gallery using ThisItem?

Scenario example:

 

Let's say I have two data sources, DATA_A and DATA_B.

DATA_A has field Name, Lastname.

And DATA_B has field Name, Lastname, Age.

 

The gallery I have can display either one of the two data sources depending on which data source the user selects using a button.

 

Inside the gallery, I have three labels to show the information of the data source (such as the Name, Lastname, and Age).

So the labels have formula that looks something like this: ThisItem.Name , ThisItem.Lastname, ThisItem.Age.

 

My problem is, when the user selects data source DATA_A, the ThisItem.Age will give me an error because that field doesn't exist in DATA_A. 

Is there a way to check if a field exists?

I want something like this for my label:

If(fieldIsExist, ThisItem.Age, "-")

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
eka24
Super User III
Super User III

I suggest you rather add a Blank Column for the Datasource without the Age as:

AddColumns(Data_B,"Age","")

 

So replace the formula with the Data_B used in your Button. 

That would remove the error as ThisItem.Age would be blank.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

 

View solution in original post

1 REPLY 1
eka24
Super User III
Super User III

I suggest you rather add a Blank Column for the Datasource without the Age as:

AddColumns(Data_B,"Age","")

 

So replace the formula with the Data_B used in your Button. 

That would remove the error as ThisItem.Age would be blank.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,595)