enter image description hereI have a SQL Table which gets updated everyday with approx 1300 to 1400 records.
I have to lookup first 200 rows and perform for-each and wait.
After completion take the next 200 rows and perform the same.
So far I have manually checked the number of rows and built the Lookup - Foreach - Wait 6 or 7 times.
Is there a way to pick the rows dynamically and run for 200 rows at a time and after completion do the same again?
This is what you do .
Add a Lookup which reads all the rows ( beware lookup has a max range of 5K , but at 1400 you are safe for now )
Add FE loop and try to reference the output of the lookup as
#activity('YourLookup activity').output.value.
Set the batch count as 200
5.Inside the FE you can put the logic as to what youw ant to do with the Lookup data .
Play around with this and you will be achieve what you intend to .
Related
Hello I've tried using text manipulation to achieve the results, and while it works - I don't think it's an efficient way to do it and there is limitations with how many times it can be done.
I was trying to figure out how to get it done with reduce but it having hard time to figure it out.
This is the current table
Unique ID
Some other Info
How many times to repeat
123
Some Info
2
456
Some Info
3
The result would be
Unique ID
123
123
456
456
456
Thank you.
Here's one way to do this:
=ArrayFormula(REDUCE("Unique ID",SEQUENCE(COUNTA(A2:A)),LAMBDA(a,c,{a;IF(SEQUENCE(INDEX(C2:C,c)),INDEX(A2:A,c))})))
Explanation
The LAMBDA inside REDUCE works by taking 3 parameters: an accumulator (a), a current value (c) and the operation to perform using them.
The accumulator (a) is initialized to the first argument of REDUCE, which is "Unique ID" and every time the inner LAMBDA is executed, the accumulator updates with the result of that execution.
The current value (c) is a variable parameter and it takes on all the values provided in the second argument of REDUCE SEQUENCE(COUNTA(A2:A)) (1).
Let's assume (1) returns:
1
2
The main work happens here:
{a;IF(SEQUENCE(INDEX(C2:C,c)),INDEX(A2:A,c))} (2)
Before this piece of code is executed, a has a value of "Unique ID" and c has a value of 1.
When it executes for the first time, a and c are replaced with their initial value, so we get:
{"Unique ID";IF(SEQUENCE(INDEX(C2:C,1)),INDEX(A2:A,1))}
Now c becomes 2 and a becomes
{"Unique ID";IF(SEQUENCE(INDEX(C2:C,1)),INDEX(A2:A,1))}
So when (2) is executed for the second time, this is what we get:
{{"Unique ID";IF(SEQUENCE(INDEX(C2:C,1)),INDEX(A2:A,1))};
IF(SEQUENCE(INDEX(C2:C,2)),INDEX(A2:A,2))}
We have now gone through all the values of c so the formula stops executing and that's effectively what it returns.
The amount of iterations REDUCE does depends on the size of its second parameter.
Let's see another example. Assume (1) returns:
1
2
3
First time c=1, a="Unique ID":
{"Unique ID";IF(SEQUENCE(INDEX(C2:C,1)),INDEX(A2:A,1))}
Second time c=2, a=PREVIOUSLY_RETURNED_ARRAY:
{{"Unique ID";IF(SEQUENCE(INDEX(C2:C,1)),INDEX(A2:A,1))};
IF(SEQUENCE(INDEX(C2:C,2)),INDEX(A2:A,2))}
Third and last time c=3, a=PREVIOUSLY_RETURNED_ARRAY:
{{{"Unique ID";IF(SEQUENCE(INDEX(C2:C,1)),INDEX(A2:A,1))};
IF(SEQUENCE(INDEX(C2:C,2)),INDEX(A2:A,2))};
IF(SEQUENCE(INDEX(C2:C,3)),INDEX(A2:A,3))}
And that's the array REDUCE returns.
Do you see a pattern?
A different approach could be-
=QUERY(FLATTEN(INDEX(SPLIT(REPT(A2:A3&"|",C2:C3),"|"))),"where Col1 is not null")
Using the following code, I've been able to query a single column properly from my dataset where B2 and B3 are drop downs that I use to filter and D1 is just a header (I have multiple queries side by side that use the same filters)
=IFERROR(QUERY('Input Sheet'!$A:$E, "select A where B = '"&$B$2&"' and C = '"&D$1&"' and D ='"&$B$3&"'",0),"")
I've tried looking it up and when I see other people use the Query function, their search area will reset upon changing their drop down filters. What I mean is, if the first query returns 4 rows and the second returns 1, only my first row will update for the query.
Updated to include sample data and video. Sorry I can't post directly into thread.
Dataset (date is excluded since it isn't relevant to my query)
Dropdowns
Query Table and Filters
Video
So if my first query has 4 rows and my next query returns only 1 row, the last 3 rows will not update.
So for example, lets say my first query returns the following:
10
19
32
41
Changing a filter will return
23
19
32
41
But in reality, the query should only return 23, the rest of the values are from the previous query. None of the videos I've watched have this problem (so none have addressed my issue)
If I change my filters to something that should return nothing (no data entries) I get the following:
"" (Empty Cell, Null etc)
19
32
41
My data source is formatted like the below
A B C D
1 2 3 4
w x y z
Any help would be appreciated. Thanks.
Often I want to quick fill of a list of time similar to how I put a 1 in A1 and then in A2 I place A1 + 1 to get two and then I copy that down the next 100 cells to get from 1 to 100. I want to do the same thing with time. It also gives me the advantage of change the first cell and updating all the times. I asked this partly because the other answers are more complex and never get to a simple solution for this kind of process that is so often used.
to populate rows with numbers from 1 to 100 use:
=SEQUENCE(100)
to get time intervals use:
=INDEX(TEXT(SEQUENCE(12, 1, 0, 2)*"1:00:00", "hh:mm:ss"))
=INDEX(TEXT(SEQUENCE(
12 +N("number of rows"),
1 +N("number of columns"),
0 +N("start from midnight"),
2 +N("interval of increase"))
*"1:00:00" +N("period of increase"),
"hh:mm:s" &N("time format")))
Working through https://spreadsheetpoint.com/add-time-in-google-sheets/ I came up with:
Make sure the cells you are working with are in the time format you desire.
Place the time you want to start with in the first cell, let's say A1
To add an hour to the time in A1, use =A1+60/(24*60), let's say in A2
Now you can copy A2 down as far in column A you desire to get the time.
Notice, the 60 in the formula =A1+60/(24*60) is the number of minutes. Hence, if you want to do a half-hour, you can use 30.
I'm using Google Sheets for our production price calculation and we are getting new orders with different data every week.
I have all the price calculations sorted out but sometimes there are the same data in orders that already been in the past and I have to manually search for it and use the same price if it exists.
As you can see in the example above, when I enter in the selected cell data "100", I have to check if it already exists in cells above (all three cell in the same row) and if it does enter its price on the cell on the right("=" sign), if it doesn't it could say "new" or be left empty.
I looked at the INDEX and MATCH functions but they don't seem to do the trick.
Do you have any suggestions? Of course the formula should be easily copied to every next cell down when new data and orders come in.
Approach
In this case it's useful to have an index for your table. I created a simple one that concatenates the 3 values you have with the & operator. You can see in the table below for the complete formula. Just drag it down to the whole table to make it automatic.
For the price calculation then I am using a VLOOKUP. It will search for the index generated by the three values in the new row and get the corresponding Price if ti exists. If not, it will print NEW. That's just a placeholder of course, you can edit it as you want. I put the first cell of your table as absolute reference in the VLOOKUP formula so you can drag it down and it will always get its upper (already filled) portion.
Table
INDEX X Y Z Price
11010030 110 100 30 1
500300100 500 300 100 2.3
12030010 120 300 10 1.2
500300100 500 300 100 2.3
12030010 120 300 10 1.2
11010030 110 100 30 1
3004510 300 45 10 NEW
11010030 110 100 30 1
=B10&C10&D10 =IFERROR(VLOOKUP(A10, $A$2:I9,5,0), "NEW")
Based on the correct initial thought by Alessandro, please use the following single arrayformula in cell E2
=ArrayFormula(IF(LEN(A2:A)>0,
IF(LEN(D2:D)>0,
VLOOKUP(A2:A&B2:B&C2:C, {A2:A&B2:B&C2:C,D2:D},2,0),"new"),""))
The formula works as a helper column, only showing you what price to use in column D (if it previously exists) or lets you know that you need to calculate a new one.
Functions used:
VLOOKUP
ArrayFormula
LEN
IF
I have to create a loop, but the size of this loop have to change according the cell value. But I don't know how to reference a specific cell.
Example - my dataset has 2 rows:
Id value
1 10
2 20
For the first row I have to run this loop 10 times, but for the second row I have to run 20 times.
How I can do this?
How about this:
loop # = 1 to 1000. /*use the maximum number or runs necessary.
do if # <= value.
some transformations.
end if.
end loop.
This will run the transformations on all cases every time, but will stop when the number of required runs for each line is reached.