Hi, I have the following SharePoint list:
With this SharePoint list I want to get a variable that increases each time the year of the column date is 2020. Therefore, in this case the variable would be equal 2.
My problem in the Flow:
In the Flow what I do inside the apply to each is a condition: FormatDateTime("COLUMN_DATE",'yyyy') equals to string('2020'). Where "COLUMN_DATE" is just the value of the Dynamic content of the column date from my SharePoint list. However, each time I run the Flow it gets only the first value of the year from the column that is 2019 and uses this value for all the apply to each. Why doesn't it loop the formatdatetime function through each value of the column date and only uses the first value?
Thank you so much for your answers and do not hesitate to ask me if some parts are not well explained.
Solved! Go to Solution.
Try it like this:
The code in the increment variable expression is like this:
if(equals(formatDateTime(items('Apply_to_each')?['Date'], 'yyyy'), '2020'), 1, 0)
Which just says if it is year 2020 then increment by 1, else 0.
Please...
If I answered your question Accept it as a solution ✔️
If I helped you out, please give me some Kudos 👍
Thanks 😙
Hello @SpaSniper ,
I'd say you're not using dynamic content provided by the 'Apply to each' action, you're using the triggerOutputs() which is a fixed value in all the loops. The correct dynamic content should be something like 'items('Apply_to_each')?...', just use the output from the 'Apply to each' instead of output of the trigger action.
Hi, if I use the output of the current 'Apply to each', I get the following error. So I don't know what to use.
Unable to process template language expressions for action 'Condition' at line '1' and column '11611': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.
Try it like this:
The code in the increment variable expression is like this:
if(equals(formatDateTime(items('Apply_to_each')?['Date'], 'yyyy'), '2020'), 1, 0)
Which just says if it is year 2020 then increment by 1, else 0.
Please...
If I answered your question Accept it as a solution ✔️
If I helped you out, please give me some Kudos 👍
Thanks 😙
I get the following error @Paulie78 😞
Unable to process template language expressions in action 'Increment_variable' inputs at line '1' and column '11613': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.
The expression I provided was:
if(equals(formatDateTime(items('Apply_to_each')?['Date'], 'yyyy'), '2020'), 1, 0)
You need to replace 'Date' with the name of your column that contains the date. If you want to troubleshoot, add a compose step with an expression of just:
items('Apply_to_each')?['Date']
(Again, replacing Date with the name of your column). This will enable you to see the value of the Date that is being manipulated.
Yes I understood @Paulie78 , the thing is, the name of my column is Date. So when I put Date in the formula it gives me the error from above.
Okay, my mistake, I got the wrong title name for the column, it appears as 'Date' but it was something strange such as 'vdoh'. Thank you so much for your help!
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!
User | Count |
---|---|
32 | |
32 | |
22 | |
22 | |
19 |
User | Count |
---|---|
56 | |
56 | |
41 | |
37 | |
29 |