cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gelos
Super User
Super User

Nested while or for loop for getting value from CDS Table

I have requirement getting value from CDS table.

1

2

3

1a

2a

3a

1b

2b

3b

I check some condition if 1 fails I will get 1a value if 1a fails I will get 1b value like that 2 and 3 so I need nested while or for loop like that java or JavaScript how can I achieve this in PowerApps then I have to check multiple conditions.

@BCLS776 

@timl 

@KrishnaV 

@RandyHayes 

@WarrenBelz 

@v-xiaochen-msft 

@Nogueira1306 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Gelos ,

 

I did a test for you.

1\ Add a button control and set its onselect property to:

ClearCollect(Col,{Value:"1",No:43},{Value:"2",No:55},{Value:"3",No:6},{Value:"1a",No:22},{Value:"2a",No:43},{Value:"3a",No:43},{Value:"1b",No:20},{Value:"2b",No:78},{Value:"3b",No:100},{Value:"1c",No:60},{Value:"2c",No:1},{Value:"3c",No:94})

 

For example: I want to find the first record that starts with 1 and meets the condition.

Condition:  No >58

 

Add a label control and set its Text property to:

First(Filter(Col,"1" in Value,No>58)).Value

 

The result is as follows:

vxiaochenmsft_0-1631153978156.png

 

Best Regards,

Wearsky

 

View solution in original post

4 REPLIES 4
BCLS776
Super User
Super User

Hi @Gelos,

As I pointed out on another thread, Power Apps does not have a For or While looping function like Javascript or VB.

 

If you can share more about how the logic you want your app to use to decide on which value to pull from your table, we can help you design an appropriate statement/statements to do that. 

 

Regards,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Thanks. I will share my logic

@BCLS776 

v-xiaochen-msft
Community Support
Community Support

Hi @Gelos ,

 

I did a test for you.

1\ Add a button control and set its onselect property to:

ClearCollect(Col,{Value:"1",No:43},{Value:"2",No:55},{Value:"3",No:6},{Value:"1a",No:22},{Value:"2a",No:43},{Value:"3a",No:43},{Value:"1b",No:20},{Value:"2b",No:78},{Value:"3b",No:100},{Value:"1c",No:60},{Value:"2c",No:1},{Value:"3c",No:94})

 

For example: I want to find the first record that starts with 1 and meets the condition.

Condition:  No >58

 

Add a label control and set its Text property to:

First(Filter(Col,"1" in Value,No>58)).Value

 

The result is as follows:

vxiaochenmsft_0-1631153978156.png

 

Best Regards,

Wearsky

 

Thank you for that

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,668)