cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dobroo
Level: Powered On

First N with variable

Hi Experts,

 

is it possible to create lines [FirstN()] with a variable?

 

I have the follwing formula:

ClearCollect(DateRange;AddColumns(FirstN([0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29];DateDiff(DataCardValue13.SelectedDate;DataCardValue14.SelectedDate;Days)+1);"Datum";DateValue(Text(DateAdd(DataCardValue13.SelectedDate;Value;Days);"[$-de-DE]dd/mm/yyyy"))))

 

This formula is limited for 30 entries.

 

My idea:

Set(counter;DateDiff(DataCardValue13.SelectedDate;DataCardValue14.SelectedDate;Days))

 

ClearCollect(DateRange;AddColumns(FirstN(counter...............

 

This counter will give me the number of lines which have to be created.

 

Or is there a better way?

 

Thx

2 REPLIES 2
Community Support Team
Community Support Team

Re: First N with variable

Hi @dobroo,

Could you please share a bit more about your scenario?

Do you want to create lines via using a variable (a Number value) within the FirstN() function?

I have made a test on my side, I afraid that there is no way to achieve your needs in PowerApps currently.

The first argument of the FirstN function is required to provide a Table value rather than a Number value. More details about the FirstN function, please check the following article:

FirstN function

 

I agree with the first formula that you provided, I think it may be the only available solution to achieve your needs in PowerApps currently.

If you would like the idea you provided to be achieved in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
dobroo
Level: Powered On

Re: First N with variable

Hi @v-xida-msft ,

 

thx for your reply. 

 

Do you want to create lines via using a variable (a Number value) within the FirstN() function?

Yes. In the function now I have the (table)array from 0-29. 

ClearCollect(DateRange;AddColumns(FirstN([0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29];......

 

If I need more than 30 lines I have to fill the array manually

ClearCollect(DateRange;AddColumns(FirstN([0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37];......

 

The required lines come from the function DateDiff()

I wanna create one entry for each day in a SP-List between two Dates (From, To). Now in the formula I create the required collection with this function

ClearCollect(DateRange;AddColumns(FirstN([0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29];DateDiff(DataCardValue13.SelectedDate;DataCardValue14.SelectedDate;Days)+1);"Datum";DateValue(Text(DateAdd(DataCardValue13.SelectedDate;Value;Days);"[$-de-DE]dd/mm/yyyy"))))

 

The Result:

DataCardValue13 = 13.02.2019

DateCardValue14 = 16.02.2019

 

Collection DateRange:

"Datum"                   Value

13.02.2019                0

14.02.2019                1

15.02.2019                2

16.02.2019                3

 

 

 

The limited Range (Table) between From-To is by 30 entries. I can expand it with the manual input as discribed above. As example FirstN[0;1;2;............................;31]...

 

My idea is that i calculate the required lines in the SP-List with the function DateDiff() as a Number variable. Then give the result (Number vaiable) as table in the FirstN() function.

 

Is this possible?

 

Best regards, 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 251 members 3,821 guests
Please welcome our newest community members: