Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

With Function and Tables Error

(0) ShareShare
ReportReport
Posted on by 17
Hi
 
I have a gallery with different data labels that will contain a value.
I asked copilot to assist in working out how to count how many of these labels contain data as that count will then be used to divide the total sum of these data labels and get the average. 
However, I am getting an error on the code that was generated and I am struggling to understand what is wrong and how I can fix it.
 
Below is the code I was given by copilot and the red is obviously the error
There are 10 data labels that contain the values of text inputs where the decimals were converted to seconds. Then what is supposed to happen is that depending on how many cycles have been done I need to divide the sum of the cycles by the number of data labels that are not blank in order to get an average.
- !Blank(Value) OR !Blank(Result) still give an error
 
Here is the actual code 
 
With(
    {
        DataLabels: [lbl_Cycle1_Sec.Text, lbl_Cycle2_Sec.Text, lbl_Cycle3_Sec.Text, lbl_Cycle4_Sec.Text, lbl_Cycle5_Sec.Text, lbl_Cycle6_Sec.Text, lbl_Cycle7_Sec.Text, lbl_Cycle8_Sec.Text, lbl_Cycle9_Sec.Text, lbl_Cycle10_Sec.Text],
        NonEmptyLabels: Filter(DataLabels, !Blank(Value)),
        Count: CountRows(NonEmptyLabels)
    },
    Value(lbl_OT.Text) / Count
)
  • Suggested answer
    SaiRT14 Profile Picture
    1,961 Super User 2025 Season 1 on at
    With Function and Tables Error
    With(
       {
          DataLabels: [
             lbl_Cycle1_Sec.Text, 
             lbl_Cycle2_Sec.Text, 
             lbl_Cycle3_Sec.Text, 
             lbl_Cycle4_Sec.Text, 
             lbl_Cycle5_Sec.Text, 
             lbl_Cycle6_Sec.Text, 
             lbl_Cycle7_Sec.Text, 
             lbl_Cycle8_Sec.Text, 
             lbl_Cycle9_Sec.Text, 
             lbl_Cycle10_Sec.Text
          ],
          NonEmptyLabels: Filter(DataLabels, !IsBlank(Value))
       },
       Value(lbl_OT.Text) / CountRows(NonEmptyLabels)
    )
  • WarrenBelz Profile Picture
    146,535 Most Valuable Professional on at
    With Function and Tables Error
    Missed that when copying your code - I have updated my original post - I  assume this is now solved and have marked it.
  • dalecombrink Profile Picture
    17 on at
    With Function and Tables Error
    Thank you Warren
     
    However I still get an error when trying to filter on Blank
    Is there another option to filter the blank values out?
     
     

    Update: I found that using !IsBlank(Value) actually works and have no errors
  • Verified answer
    WarrenBelz Profile Picture
    146,535 Most Valuable Professional on at
    With Function and Tables Error
    You need to chain the With() elements as they cannot be dependant on other elements in the same statement
    With(
       {
          DataLabels: 
          [
             lbl_Cycle1_Sec.Text, 
             lbl_Cycle2_Sec.Text, 
             lbl_Cycle3_Sec.Text, 
             lbl_Cycle4_Sec.Text, 
             lbl_Cycle5_Sec.Text, 
             lbl_Cycle6_Sec.Text, 
             lbl_Cycle7_Sec.Text, 
             lbl_Cycle8_Sec.Text, 
             lbl_Cycle9_Sec.Text, 
             lbl_Cycle10_Sec.Text
          ]
       }
       With(
          {
             NonEmptyLabels: 
             Filter(
                DataLabels, 
                !IsBlank(Value)
             )
          },
          Value(lbl_OT.Text) / CountRows(NonEmptyLabels)
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,535 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,908 Most Valuable Professional

Leaderboard