cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mokhawaja
Level 8

condition "not equal' results in multiplcated results

Hi,

i am building a complex flow that checks if my reps posted their reports for yesterday or not, if YES, they will get a thank you email, and if NOT, they will get a reminder to post their reports.

here is the details:

i am using CDS with custom enteties "Medreps" and "Daily Report Headers", first i get the list of records of both entities, and get the user profile to get the display names of the "CreatedBy" field in "Daily Report Headers"... 

 

example:

Medreps entitiy contains the following names:

  1. Salim
  2. Ali
  3. Lara
  4. Mona
  5. Ahmed

but when checking yesterday reports, only Salim and Lara posted their reports, then when i reach to the condition which checks if : MedReps Name = Display Name it results the following:

If Yes: (Send Thank you email)

  1. Salim
  2. Lara

(which is good and wanted result)

but...

If Not: (send reminder email)

  1. Salim (wrong)
  2. Lara (wrong)
  3. Mona
  4. Mona (duplicated)
  5. Ali
  6. Ali (duplicated)
  7. Ahmed
  8. Ahmed (duplicated)

 

which means the total results of (if Not) will always be [( total no of Reps * total reports)-total reports],

Screenshot (23).png

 

Screenshot (9).png

 

 

appreciate your help to modify my condition or the flow if possible!

 

regards,

Mohammad

2 REPLIES 2
Community Support Team
Community Support Team

Re: condition "not equal' results in multiplcated results

Hi @mokhawaja,

 

Could you please show a bit more about custom entities "Medreps" and "Daily Report Headers"?

Could you please show more details about the Active field in Condition box?

I suppose that there is a column that check if the report is posted in custom entity “Daily Report Headers”. On my side, I create an Active field to check if the report is posted in custom entity “Daily Report Headers”.

I think there is something wrong with your “Apply to each 2” action. Within “Apply to each 2”, each of  users in custom entity “Medreps” would perform these steps for two times if two users post their report.

Besides, I don’t think “Apply to each 2” is appropriate in your flow, please take a try with the following workaround:

  • Add Recurrence trigger.
  • Add “Get lists of records” action, specify database and entity, The entity set to Medreps entity.
  • Add “Get lists of records 2” action, specify database and entity, The entity set to Daily Report Headers entity.
  • Add “Apply to each”, input parameter set to output of “Get lists of records 2” action.
  • Within “Apply to each”, add a Condition, left input box set to Active content of “Get lists of records 2” action, right input box set to true. In middle drop down, choose “is equal to”.
  • Within “If/yes” branch of “Condition”, add “Get user profile” action, then add “Filter array” action. After “Filter array” action, add a Condition 2, click “Edit in advanced mode”, type the following formula:

 

@not(empty(body('Filter_array')))

Within “If/yes” branch of “Condition 2”, add “Send an email” action.

 

  • Within “If/no” branch of “Condition”, repeat above step.

Image reference:2.JPG

 Within "If/yes" branch of Condition:3.JPG

 Within "If/no" branch of Condition:4.JPG

 The flow works successfully as below:5.JPG

Note: 
You can upload a pbix file to Onedrive or any web storage and share the link. Do mask sensitive data before uploading. 

 

Best regards,

Kris

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.
mokhawaja
Level 8

Re: condition "not equal' results in multiplcated results

hi @v-xida-msft,

sorry for the late reply to your post i was really busy on other urgent projects.

 

that's one great post from your side to help, which i learned a lot from especially the Filter array, but unfortunately it did not solve my problem, may be due to some lacking info from my side:

 

MedReps entity contains my employees list (Medical sales reps), names and other details.

in the Daily report Headers entity contains the daily report of each MedReps. (where each medical rep records his/her actual daily work)

and by the way there is no established relationship between the 2 entities (i depend on the CreatedBy field in the DailyReport entity to extract the name of the Medrep).

 

 and for the Active field... inside the MedReps entity which states if the medrep is Active or Inactive (they resigned or out of the position), so i don't want to send these "inactive" reps emails reminding them to send their reports, while they are out of the company!!

 

again i tried your solution and tried to modify it so many times with no success... i think i should use a different approach for the condition, because this condition trys to find a match for each medrep into the display name of CreatedBy field from Daily Reports Headers entity... for example:

if i have three medreps Mark, John & Mona, and when checking yesterday's reports in the Daily reports Header, Mark & John sent their reports, but Mona  did not. 

so this condition now does the following: for each Medrep (Mark, John & Mona) it will check against (Mark & John

see this description:

Screenshot (25).png

 

 

 

sorry for making it so long, but tried to elaborate as much as i can.

 

thanks again for your help.

Mohammad

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 164 members 6,110 guests
Please welcome our newest community members: