cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

string array from json

Hello everyone, 

 

I am trying to import a nested json file and later on compare the receipt-number with another number from an rather large excel file. In the end I want to send a Mail if any receipt number is missing in my excel file.

What I've done so far is importing my json file and parsing it. I tried to compare the values by using apply to each, but the comparison does not seem to work. I suppose that's because I would need an array with strings, but I don't really know to to get there. Any advices would be greatly appreciated!

 

My file looks like this:
{
"infos": {
"numPages": 1
},
"entities": {
"service ": {
"date": "26.12.2020",
"currency": "EUR",
},
"receipt": [
{
"number": "1218182",
"datum": "20.12.2020",
"betrag": "977,34",
"fälligkeit": "20.12.2020"
},
{
"number": "38272",
"datum": "02.12.2020",
"betrag": "5621,58",
"fälligkeit": "02.12.2020"
},
{
"number": "39328",
"datum": "26.12.2020",
"betrag": "1817",
"fälligkeit": "26.12.2020"
},
{
"number": "2181",
"datum": "02.12.2020",
"betrag": "1092",
"fälligkeit": "16.12.2020"
},
{
"number": "161728",
"datum": "02.12.2020",
"betrag": "1839",
"fälligkeit": "16.12.2020"
},
{
"number": "82726",
"datum": "03.12.2020",
"betrag": "1023",
"fälligkeit": "17.12.2020"
},
{
"number": "635272",
"date": "03.12.2020",
"betrag": "123",
"fälligkeit": "17.12.2020"
}
]
}
}

6 REPLIES 6
yvett
Frequent Visitor

Hi Fabian,

I've had a similar issue a few days ago, and the only way i found around it was with a few loops and conditions. 

First, I put the whole json code into a "compose", and save its output into a string variable. I also initialize 2 arrays, the first one we get from the "text" string variable, but I split it at the character '{'; the second one i leave empty:

Step 1Step 1

 For step two, i loop through all of the items in the "array", and only select the items that contain "number" in them. I set these items to my "text variable and then split them by the ',' character to be able to loop through them again. 

Step 2Step 2

 

Once I have got the array, i loop through its items once more, and only select the ones that contain "number" (once more!) the value now should look like ""number": "1218182"" i set the text to this value, and split it by the ":" character

Step 3Step 3

 Finally, i loop through my array (that should only contain 2 items) and only select the item that does not contain "number" and append it to the array of "final_numbers"

Step 4Step 4

 

 

I know it looks awkward and can take a while to go through it, but make sure to enable concurrency on your loops and it'll go significantly quicker. I hope it works!

As a confirmation, after these nested loops, I checked the output by simply setting the first array to the array of outcomes. once you run it, this should only include the numbers you wanted. 

checkcheck

 

From here on, you should be able to work out the next step to compare the numbers. 🙂 

 

Kind regards, 

Yvett 

Anonymous
Not applicable

Hi Yvett, 

 

Thanks for sharing your solution! I tried it immediately. I ran into one issue I don't really get. Within the first loop the current items seems to change. In the end I get an array that consists either of 12 entries of the same number, or several repetions of 2. 

 

Checking the output I found that within the first loop, the split function does something weird. Insted of using the Input text, that refers to the numbers in correct order, it take some other entry from my json file. Did you run in the same issue? test.pngScreenshot (5).pngScreenshot (4).png 

Again, thanks a lot!

 

Best, 

 

Fabian 

I think you need a slightly different approach. It would be helpful if you could screenshot your entire flow. 

 

In short terms you need to:

  1. Read the Excel file once only at the start of the flow.
  2. Extract the array from your JSON, which is simply to do and I can show you how if you post your current flow.
  3. Loop over that array.
    1. Within the loop you will filter the Excel data based on the current iteration of the loop array.
    2. Check the length of the filter, if it is zero then the entry is missing.
    3. If it was greater than zero, add the current loop item to a new array.
  4. At the end of the loop you will have an array containing only the missing entries.

Does that make sense?

Anonymous
Not applicable

Hi @Paulie78 , 

I attach the flow and provide some explanation: 

1) I import the the json file from my sharepoint 

2) I initialize a variable to pass it to the parse Json function  

3) I parse the json formatted data

4) In the next step I import the excel file. the column reference is supposed to be used for my later comparison 

5) I use the function select, to select exactly this column 

6) I create two arrays that I use to test whether my comparison works

7) I loop through each 'number_ element which is nested within the 'rechnung' array. My condition is: If the output of the select function (which is the reference column from my excel) contains the current element.. 
😎 If the condition is true, I append the current elemt to the test array match. If it's false, I append it to the test array no match. 

9) In the last step I simply compose those test arrays

 

Unfortunately I get an error message, because the apply to each function requires a different input format. That's why I was wondering how to extract the number information in a format that I could use as Input in my apply to each function.
Your suggestion is in general correct, but I don't need to check whether the arrays match in total, but whether each single number-entry in my json file is listed in the excel file. 

 

I would be really greatful for some advice! Thanks in advance!

 

Best, 

 

FabianScreenshot (10).pngScreenshot (11).pngScreenshot (12).png

Hi Fabian, 

 

No, unfortunately I didn't get any errors, I copy pasted the code you had in the original post and did exactly what's on the pictures, i got the right values, however, i can see that yours is splitting it at a different place than mine, could it be the input is somewhat different? Are you splitting it the same way? If you have concurrency turned on, that can mess with things if it's not correct, try maybe without it first? 

 

I hope you got it working over the weekend! 🙂 

 

Kind regards, 
Yvett 

It's really difficult to explain, but you do not need the multiple apply/each loops. You simply need to go into your apply/each loop with your "number_ element". Then instead of looping through each Excel row to see if there is a match, you simply filter the Excel data using the "filter array" function.

 

If there is a match, the length of that filter array will be greater than zero, if there is no match it will be zero. By using this method your flow will be much faster, and much more simple. 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,652)