cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dobroo
Advocate II
Advocate II

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
v-xida-msft
Community Support
Community Support

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.

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (47,146)