cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gelos
Post Partisan
Post Partisan

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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (3,217)