How to save bucket names to a string and add new ones after that to an array - arrays

i have planner buckets (Tasks, in progress, Backlog) and I want to create a new Bucket depending on elements in a SharePoint list.
But I can't save the bucket names to an array and then add the missing value e.g. like "on hold" and the go trough the array again. It always set my array to blank again.
Maybe you can help me. Here is my PowerAutomate Flow so far:

You could use a couple of Select actions to create two arrays which you can use for the comparison. With a Filter Array you can find the ones which are missing. The output of that Filter Array can be used to loop through and create the missing buckets.
Below is an example of that approach.
1. In both Select actions the Map field is switched to text mode to only get Arrays with values (without keys)
2. In the Filter Array this is used in the From
body('Select_-_SharePoint_Items')
3. And this is the expression used in the advanced mode
#not(contains(body('Select_-_Existing_Buckets'), item()))

Related

Convert CSV elements into a single Array using Azure Logic Apps

I have a csv file which has the following sample values
ReportId,ReportName
1,Poy
2,Boy
3,Soy
I want this to be converted into a single array like
[ReportId,ReportName,1,Poy,2,Boy,3,Soy]
using logic apps.
Is this possible?
You could refer to my below flow. Init a csv data, then split with expression split(outputs('Compose'),'\n'), you need to go to code view to edit the expression, or it would be split(outputs('Compose'),'\\n').
Then do the loop action to get the single data. The for each 2 input is split(item(),','). Then append the current item to the array.
Here is my result.

Select the data from input

My app uses a select with different values, which work also as a search. Now if i click on save after i inserted 2 names i get an an array with 2 objects. After that if i will insert just 1 name and click save, the previous array is changed with a new one which is composed only from 1 element, in fact i deleted the first array, but i don't want to lose the previous array. I want to keep the previous array, and if i will add a value that not exists in it, i want to add the new value, and i fact i will have an array with 3 objects. How to solve this issue?
link to my app: https://codesandbox.io/s/affectionate-ritchie-oxhuk
Basically what you need to do, is to save after every Save buton click(i.e. to concat arrays) and save only the unique items.
if you are familer with ES6, you can use Set object of javascript. Its an handfull tool to choose unique items from an array.
Array.from(new Set(savedItems.concat(selectedItems)).values())
you can first concat the two array, then set them to a Set to remove the duplicates and then convert them back to the original Array.
https://codesandbox.io/s/objective-pascal-5fo3n

How to return an array matching a certain criteria in Excel?

I'm trying to parse an XML file in Excel, which is a Japanese dictionary. It contains several translations of each entry into different languages, and some entries have multiple translations per language. I want to write a formula that finds all of the translations by their language code, returns them as an array, and concatenates them using a TEXTJOIN formula. But I don't know how to go about this in Excel.
In Google Sheets, this would be easily solved by a FILTER function, but I can't use Sheets as there's too much data, and I haven't managed to get access to the beta FILTER function yet.
In the below picture, I'm trying to return the values in the <gloss xml:lang*> column, by searching for the values in the lang column. So for example, I want to return all values which have a "dut" next to them, and concatenate those into a single line using TEXTJOIN.
Any idea how I could go about doing this?
I fixed this by downloading the FILTER function. This is part of the Office Insider program, which releases Beta features if you choose to participate. You can access the Insider program by going to File > Account > Office Insider. Then to update your Office version go to File > Account > Office Updates to install the Insider update.
To filter the list by the "lang" column the formula looked like:
=FILTER([range in H column], [range in I column]=T$2)
I haven't specified either range because I used a formula-defined range using the INDIRECT function to avoid filtering through a million rows. The H range is what I want in the results of the filter, the I range is what I want to filter by - the "lang" code. T$2 represents the "lang" code, in this case "dut", and when I copy it across it will filter by each of the 8 lang codes in Row 2.
Then I used TEXTJOIN to combine it the array result into one column using the comma separator:
=TEXTJOIN(", ", TRUE, FILTER(...))

How to update keys in a JSON array Postgresql

I am using PostgreSQL 9.4.1 and have run into an issue with a column that I need to update. The column is of type JSON with elements in the following format:
["a","b","c",...]
["a","c","d",...]
["c","d","e",...]
etc.
so that each element is a string. It is my understanding that each of these elements are considered keys to the JSON array (please correct me if I am a bit confused here, I haven't ever worked with JSON datatype columns before, so I'm still trying to get a grip on them anyways). There is not an actual pattern to these arrays, and their contents are dependent on user input from somewhere else. My goal is to update any of the arrays that contain a particular element (say "b" for the purpose of explaining my question more thoroughly) and replace the content "b" with say "b1". Meaning that:
["a","b","c",...]
would be updated to
["a","b1","c",...]
I have found a few ways listed on this site (I don't currently have the links, but I can find them again if necessary) to update VALUES for a particular KEY, but I haven't found a way mentioned to change the KEY itself. I have already found a way to target the specific rows of interest by doing something similar to:
SELECT *
FROM TableA
WHERE column::json ?| ["b", other string elements of interest]
Any suggestions would be greatly appreciated. Thanks for your help!
So I went ahead and gave that a check (because it looks like it should work, and it's more or less what I ended up doing), but I figured out what I was trying to do! What I got was this:
UPDATE TableA
SET column = REPLACE(column::TEXT,'b','b1')::JSON
WHERE column::JSON ?| ['b']
And now that I think about it, I probably don't even need the last where condition because the replace won't affect anything that doesn't have 'b' in it. But that worked for me, and it looks like yours probably should too! Thanks for the help!
I wanted to rename a specific key for json array column.
I tried and it worked on PostgreSQL 9.4:
UPDATE Your_Table_Name
SET Your_Column_Name = replace(Your_Column_Name::TEXT,'Key_Old_Name','Key_New_Name')::json
WHERE attributes::jsonb ? 'Key_Old_Name'
Basically, solution is to go over the list of json_array_elements, and based on json value using CASE condition replace certain value with other one. After all, need to re-build new json array using array_agg() and to_json() description of aggregate functions in psql is here.
Possible query can be the following:
-- Sample DDL and JSON data
CREATE TABLE jsontest (data JSON);
INSERT INTO jsontest VALUES ('["a","b","c"]'::JSON);
-- QUERY
WITH result AS (
SELECT to_json( -- creating updated json structure
array_agg( -- create array with new element "b1"
CASE WHEN element::TEXT = '"b"' -- here we process array elements to find "b"
THEN to_json('b1'::TEXT)
ELSE element
END)) as new_json
FROM jsontest,json_array_elements(jsontest.data) as element
)
UPDATE jsontest SET data = result.new_json FROM result;

Excel array function return all fields found with index and match

Here is the array function I am using:
=IFERROR(INDEX('Master Data'!$D$2:$D$153,MATCH(1,(B9='Master Data'!$J$2:$J$153)*('Master Data'!$W$2:$W$153=1),FALSE)),"")
Where D is the name of a project, J is a persons name and W is a flag to check if they are assigned to a project either equal to 0 or 1. B is also an instance of the persons name that is built up from a seperate list.
It basically references the master data and returns any rows with the criteria specified. However a single person may have two instances where the assigned flag is equal to 1 and thus as the master data is filtered different results are given back by the function.
Another problem I have is that the persons name is not repeated either so maybe the best way would be to start populating the names in the assigned table from the master data as well.
As requested here is an slight example of the data. On the left is the master data, the middle is the assigned table thats being built and the right is the list of employees that builds up the names in the assigned table.
Please note that there is two instances of david smith in the master data but only one in the assigned table as its being built with the employees list.
What I was thinking was to build up the names in the assigned table from the master data using an array where the assigned indicator is equal to 1 and to completely scrap the employees list, but I'm really unsure if this is possible or how to go about it.
Or even if there was some sort of way to select a few columns from the master data where the assigned indicator = 1?
Not sure if I understood it right. But the problem how to list multiple lookup results is achievable with SMALL function in combination with getting an array of ROW numbers.
For example have a sheet like this:
Then formulas are:
F4 downwards:
=COUNTIFS($B:$B,$E4,$C:$C,1)
G4 and then copied in G4:J8:
{=INDEX($A$1:$A$1000,SMALL(IF($B$1:$B$1000=$E4,IF($C$1:$C$1000=1,ROW($1:$1000))),COLUMN(A:A)))}
But if the goal is only to have a filtered list of all assigned resources, then the formulas could be
E13:
{=INDEX($B$1:$B$1000,MATCH(1,($C$1:$C$1000=1)*1,0))}
E14 downwards:
{=INDEX($B$1:$B$1000,MATCH(1,(COUNTIF($E$13:$E13,$B$1:$B$1000)=0)*($C$1:$C$1000=1),0))}
Formulas in {} are array formulas. These are entered into the cell without the curly brackets and then [Ctrl]+[Shift]+[Enter] is pressed to finish.
I have not handled the error values for better understanding the formulas. You can later hide the error values with IFERROR. You seems to know how to do this.

Resources