cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tamer66
Helper III
Helper III

check is a collection field empty

Hi Forum,

 

i want to check is a field in my collection empty or not. 

If a specific field emty, i want to disable a button

 

Example for a button diplaymode property:

If(IsBlank(collection.field);DisplayMode.Disabled;DisplayMode.Edit)

 

This is not working, anyone know another way?

 

Thanks & greets

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

The problem is that you can't check whether a collection field is empty, you have to check whether a field is empty for a record in a collection.  Even if there is only one record you have to reference the record to get the field value.  So assuming you only have one record in the collection then the formula you need is:

If(IsBlank(First(mycollection).test),DisplayMode.Disabled,DisplayMode.Edit)

If you have more than one record you have to do something to get the specific record and then check the field in the record.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
Pstork1
Dual Super User III
Dual Super User III

The problem is that you can't check whether a collection field is empty, you have to check whether a field is empty for a record in a collection.  Even if there is only one record you have to reference the record to get the field value.  So assuming you only have one record in the collection then the formula you need is:

If(IsBlank(First(mycollection).test),DisplayMode.Disabled,DisplayMode.Edit)

If you have more than one record you have to do something to get the specific record and then check the field in the record.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

ericonline
Community Champion
Community Champion

Hi @Pstork1 and @Tamer66 .

Here is a method I successfully use to determine if a particular column within a Collection contains blank values or not:

 

Filter(colTest, IsBlank(columnName))

 

You can do things like this to check multiple columns for blanks:

 

If(
    CountRows(
        Filter(colTest, 
            Or(
                IsBlank(columnName1),
                IsBlank(columnName2),
                IsBlank(columnName3)
            )
        )
    ) > 0,
    "x",
    "y"
)

 

 Hope this helps!

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,133)