cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MichVer
Frequent Visitor

Trigger mail by items of calculated collumn (date)

Hi,

 

I'm trying to build a flow to trigger a calculated date inside a sharepoint list.

If the calculated date is equal to present date, I would like to send a mail.

 

My calculated date [Date Alert] isn't triggering anything.

If I replace this date collumn with a normal date collumn, the flow works just fine.

Conclusion: calculated items don't work inside Power Automate? Or is there a solution/workaround for this?

 

I used the formatDateTime(utcNow(),'yyyy-MM-dd'expression in the condition.

 

Knipsel.PNG

 

Thank you in advance!

 

Best regards.

1 ACCEPTED SOLUTION

Accepted Solutions
MarvinBangert
Most Valuable Professional
Most Valuable Professional

Hi @MichVer 

Please see the following list, it should be quite like yours:

MarvinBangert_0-1675292055727.png

I have a "Date" column from column type "Date and Time" (only Date):

MarvinBangert_1-1675292119435.png

I have a choice field "MeasurementType":

MarvinBangert_2-1675292148094.png

And I have a calculated colum "AlertDate":

MarvinBangert_3-1675292182206.png


I created four different items; we would like to get the items that have "true" in the name as the alert date is the current date (2/2/2023 or 2023-02-02). Using the filter query in Power Automate is using a REST API Filter towards SharePoint (read more here, but it's very developer orientated and just a basic overview how SharePoint REST API works). As I already said, calculated columns are not supported within this filter query, so we would need to use another column. As the "Alert date" is just calculated from a date column and a choice column, we can redo the calculation within Power Automate and within the filter query.

For the filter query you can basically think about it like:

Without a filter query, you are telling SharePoint "Give me just all items, I will do the work by myself to get the right stuff". With a filter query you are telling SharePoint "I just want to have these items, do the work for me". For SharePoint this is an easy task, so SharePoint just uses your filter and checks on every item if the filter applies to this and returns you all the items the filter applies to.

 

The filter query follows a specific pattern, so that SharePoint is able to look for the right stuff:

 

<SharePoint internal column name> <comparison> <value>

 

(Sometimes there are also other patterns like startswith() or substringof(), but that shouldn't be part for today, this query is called "OData query" you can read more here (again focusses on developers)).

 

Your calculated column is a bit more complex, but we will go through it step by step and combine them all together in the end.

1. First, we want to filter for the "Measurement Type". This is easier, as we just need to give a value it should look for, without any expression written yet. You always need the internal SharePoint column name (the Displayname can be different). Within your list click on the steering wheel - List settings - select your column - check the URL:

MarvinBangert_4-1675293390277.png

At the very end of the URL, you will see the unique and internal name of your column, that is the one we need within the filter query:

MarvinBangert_5-1675293486527.png

next we need the comparison, it's often shortened, e.g., "equals" is "eq", "less or equal to" is "le", "greater or equal to" is "ge", "not equal" is "ne". You will easily find some blog posts using your favorite search engine about SharePoint filter queries and comparisons you can use. Finally, we need to tell SharePoint what value it should look for, in this case it should look for 'Inter-Instrument'. If you are looking for a word (or called string) or date, you need to use single quotes, if you are looking for a number you can leave them.

 

If you run the filter query from above, you would receive only the items from SharePoint where the Measurement Type is Inter-Instrument. As from your calculated column, we also need to check for the date as it could be different for "Inter-Instrument" and "Inter-Period". That is the next thing we will do:

 

Same again, look for the internal column name, but now for the value we need to do some calculation:

MarvinBangert_6-1675293972623.png

Before the query is sent to SharePoint, Power Automate will turn the expression into a value and this value is then compared within SharePoint to only select the values you are looking for. Here is the expression:

 

addToTime(utcNow(),-3,'Month','yyyy-MM-dd')

 

Here you can see the parameters "addToTime()" requires: Reference guide for expression functions - Azure Logic Apps | Microsoft Learn

First the timestamp "utcNow()", this will give the current date and time the flow runs (as already explained, as the flow runs each day, it will always be the current date and time). Next the interval or number of a unit to add, if you put a minus infront, it will subtract. Next the time unit used with the interval, this could be "Second", "Minute", "Hour", "Day", "Week", "Month" or "Year". Next the format the date and time should be returned to. If you let your flow run first (with or without any filter arrays), you will get some JSON and you can also see the format the date is returned as:

MarvinBangert_7-1675294350182.png

Usually, dates are returned as "yyyy-MM-dd".

Again, if you run your flow, it should only return values where the date is "2022-11-02" ("2023-02-02" (today) - 3 Months)

 

Now we need to combine these two queries together as we want to only get the items where the Measurement Type is equal to "Inter-Instrument" and the date equal to "2022-11-02". To combine queries, you can use "and" or "or". With "and" both needs to be true and or only one needs to be true. We need "and" as both needs to be true:

MarvinBangert_8-1675294721501.png

You can add brackets around the individual queries to make it look clearer where a query starts and ends. This will just return all items where Measurement Type is "Inter-Instrument", and date is "2022-11-02".

Using the, we can also extend the query to include the "Inter-period" and date is "2022-02-02" (One year ago), we can just combine these two queries using "or":

MarvinBangert_9-1675295002059.png

 

((MeasurementType eq 'Inter-Instrument') and (Date eq '@{addToTime(utcNow(),-3,'Month','yyyy-MM-dd')}') or (MeasurementType eq 'Inter-Period') and (Date eq '@{addToTime(utcNow(),-1,'Year','yyyy-MM-dd')}'))

 

 

Here is the result:

The list with all items:

MarvinBangert_10-1675295054886.png

The flow action with the filter query:

MarvinBangert_12-1675295305080.png

The result (I am using a "create HTML table" action to format the results as a table:

MarvinBangert_13-1675295470253.png

 

Last tipp: if you don't want to send individual emails (or teams message), you can also use a "Create HTML table" to format the results and send this to yourself (or someone else):

MarvinBangert_14-1675295734891.png

Result:

MarvinBangert_0-1675296760938.png

 

Does this help you? Otherwise please give me some more information.

Best regards
Marvin

If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

Blog: Cloudkumpel
Join my User Group (German & English): Power Platform UG Cologne

View solution in original post

5 REPLIES 5
MarvinBangert
Most Valuable Professional
Most Valuable Professional

Hi @MichVer 

You can use calculated columns within Power Automate, they are just not working if you try to use the "filter query" within "get items". Could you please share how the "Alert date" values are formatted? As you are using an "is equal to", the date must be exactly the same, maybe there are more information saved within the "Alert date" (like time) which will not make this work, because the condition is:

"2023-02-01" is equal to "2023-02-01Z00:00:00"

this will always be false.

 

I would recommend also changing the flow to make it more efficient. Currently (if you don't use any filter query within the get items) you are loading all items from the list into your flow and "apply to each" runs through all of them. If you have 500 items and your flow only runs on 2 of them, this is very inefficient. You can use the "filter query" action within "get items" to just get the items you are looking for and don't need to check later using a condition.

As I already said, you are not able to filter on a calculated column, but (depending on your SharePoint calculated formular) you can rebuild it. e.g., if your "Alert Date" is always 14 days before a "Due Date" column and "Due Date" is a date field, you can write this as an expression within Power Automate:

addDays(utcNow(),14)

This will add 14 days to the current date (as your flow maybe starts every day, each day it will be always the current date) and this date could be the due date, so we need to compare it.

The formular you now add inside the "Filter Query" of your SharePoint action could look like:

DueDate le '@{addDays(utcNow(),14)}'

"DueDate" is the internal SharePoint column name (if you have spaces, it's "Due_x0200_Date"); le stands for "less or equal to" and our expression. So "Get all items if 'Due Date' is less or equal to today+14 days" is the query send to SharePoint and you will only receive the items you are looking for.

Afterwards you can just add the "Send an email" action for each item that is returned and you don't need to use the condition.

 

Here is also some (longer) information how to do it: Power Automate filter on SharePoint Date and Time column (tomriha.com)

 

Does this help you? Otherwise please give me some more information.

Best regards
Marvin

If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

Blog: Cloudkumpel
Join my User Group (German & English): Power Platform UG Cologne

Andrew_J
Memorable Member
Memorable Member

Can you see the calculated column in the first part of the condition. As both sides of this need to match. Also look at putting each part of the condition into a separate compose before the apply to each.

Hi @MarvinBangert ,

 

Thank you for your reply. 

 

The Date Alert value is calculated as follows:

 

=IF([Measurement Type]="Inter-Instrument",DATE(YEAR(Date),MONTH(Date)+3,DAY(Date)),
IF([Measurement Type]="Inter-Period",DATE(YEAR(Date)+1,MONTH(Date),DAY(Date))))

 

BUT I think I want to go with your alternative. It sounds much more efficient. The purpose of the flow is to trigger a reminder mail 3 months after the measurement date [Date] that's being added inside the list.

 

Did I get it right that you said DueDate is a variable and not a custom made collumn? I'm not (yet) familiar with the functionality of filter query. How does this option know which column is to check inside the list? 

 

If you need more information just ask and I will try to give it to you.

 

Best regards.

 

Knipsel.PNG

 

MarvinBangert
Most Valuable Professional
Most Valuable Professional

Hi @MichVer 

Please see the following list, it should be quite like yours:

MarvinBangert_0-1675292055727.png

I have a "Date" column from column type "Date and Time" (only Date):

MarvinBangert_1-1675292119435.png

I have a choice field "MeasurementType":

MarvinBangert_2-1675292148094.png

And I have a calculated colum "AlertDate":

MarvinBangert_3-1675292182206.png


I created four different items; we would like to get the items that have "true" in the name as the alert date is the current date (2/2/2023 or 2023-02-02). Using the filter query in Power Automate is using a REST API Filter towards SharePoint (read more here, but it's very developer orientated and just a basic overview how SharePoint REST API works). As I already said, calculated columns are not supported within this filter query, so we would need to use another column. As the "Alert date" is just calculated from a date column and a choice column, we can redo the calculation within Power Automate and within the filter query.

For the filter query you can basically think about it like:

Without a filter query, you are telling SharePoint "Give me just all items, I will do the work by myself to get the right stuff". With a filter query you are telling SharePoint "I just want to have these items, do the work for me". For SharePoint this is an easy task, so SharePoint just uses your filter and checks on every item if the filter applies to this and returns you all the items the filter applies to.

 

The filter query follows a specific pattern, so that SharePoint is able to look for the right stuff:

 

<SharePoint internal column name> <comparison> <value>

 

(Sometimes there are also other patterns like startswith() or substringof(), but that shouldn't be part for today, this query is called "OData query" you can read more here (again focusses on developers)).

 

Your calculated column is a bit more complex, but we will go through it step by step and combine them all together in the end.

1. First, we want to filter for the "Measurement Type". This is easier, as we just need to give a value it should look for, without any expression written yet. You always need the internal SharePoint column name (the Displayname can be different). Within your list click on the steering wheel - List settings - select your column - check the URL:

MarvinBangert_4-1675293390277.png

At the very end of the URL, you will see the unique and internal name of your column, that is the one we need within the filter query:

MarvinBangert_5-1675293486527.png

next we need the comparison, it's often shortened, e.g., "equals" is "eq", "less or equal to" is "le", "greater or equal to" is "ge", "not equal" is "ne". You will easily find some blog posts using your favorite search engine about SharePoint filter queries and comparisons you can use. Finally, we need to tell SharePoint what value it should look for, in this case it should look for 'Inter-Instrument'. If you are looking for a word (or called string) or date, you need to use single quotes, if you are looking for a number you can leave them.

 

If you run the filter query from above, you would receive only the items from SharePoint where the Measurement Type is Inter-Instrument. As from your calculated column, we also need to check for the date as it could be different for "Inter-Instrument" and "Inter-Period". That is the next thing we will do:

 

Same again, look for the internal column name, but now for the value we need to do some calculation:

MarvinBangert_6-1675293972623.png

Before the query is sent to SharePoint, Power Automate will turn the expression into a value and this value is then compared within SharePoint to only select the values you are looking for. Here is the expression:

 

addToTime(utcNow(),-3,'Month','yyyy-MM-dd')

 

Here you can see the parameters "addToTime()" requires: Reference guide for expression functions - Azure Logic Apps | Microsoft Learn

First the timestamp "utcNow()", this will give the current date and time the flow runs (as already explained, as the flow runs each day, it will always be the current date and time). Next the interval or number of a unit to add, if you put a minus infront, it will subtract. Next the time unit used with the interval, this could be "Second", "Minute", "Hour", "Day", "Week", "Month" or "Year". Next the format the date and time should be returned to. If you let your flow run first (with or without any filter arrays), you will get some JSON and you can also see the format the date is returned as:

MarvinBangert_7-1675294350182.png

Usually, dates are returned as "yyyy-MM-dd".

Again, if you run your flow, it should only return values where the date is "2022-11-02" ("2023-02-02" (today) - 3 Months)

 

Now we need to combine these two queries together as we want to only get the items where the Measurement Type is equal to "Inter-Instrument" and the date equal to "2022-11-02". To combine queries, you can use "and" or "or". With "and" both needs to be true and or only one needs to be true. We need "and" as both needs to be true:

MarvinBangert_8-1675294721501.png

You can add brackets around the individual queries to make it look clearer where a query starts and ends. This will just return all items where Measurement Type is "Inter-Instrument", and date is "2022-11-02".

Using the, we can also extend the query to include the "Inter-period" and date is "2022-02-02" (One year ago), we can just combine these two queries using "or":

MarvinBangert_9-1675295002059.png

 

((MeasurementType eq 'Inter-Instrument') and (Date eq '@{addToTime(utcNow(),-3,'Month','yyyy-MM-dd')}') or (MeasurementType eq 'Inter-Period') and (Date eq '@{addToTime(utcNow(),-1,'Year','yyyy-MM-dd')}'))

 

 

Here is the result:

The list with all items:

MarvinBangert_10-1675295054886.png

The flow action with the filter query:

MarvinBangert_12-1675295305080.png

The result (I am using a "create HTML table" action to format the results as a table:

MarvinBangert_13-1675295470253.png

 

Last tipp: if you don't want to send individual emails (or teams message), you can also use a "Create HTML table" to format the results and send this to yourself (or someone else):

MarvinBangert_14-1675295734891.png

Result:

MarvinBangert_0-1675296760938.png

 

Does this help you? Otherwise please give me some more information.

Best regards
Marvin

If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

Blog: Cloudkumpel
Join my User Group (German & English): Power Platform UG Cologne

Hi @MarvinBangert ,

 

Worked like a charm! Thank you. Well explained too.

I still added a condition, but only to send 2 seperate mails depending on User Location.

 

Best Regards,

Michiel

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,460)