cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BQC
Level: Powered On

count if value is current date

Hello,

I'm trying to make a counter for my app. I want it to count how many items that matches the todays date, as it will work as project planning. On the below picture there is seen two instances which is the same as the current date (20-02-2019)

image.png

 

I have been trying to make a counter for this.

the current (non-working) code i have is;

CountIf(Gallery12.AllItems;Text([@Title13])=Today())

The title 13 is the date in the gallery and i want it to count if it matches the current date.

Any ideas how to resolve this issue?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: count if value is current date

Hi @BQC ,

I have made a test on my side, and don't have the issue that you mentioned. The screenshot as below:2.JPG

On your side, please take a try with the following formula:

CountIf(Gallery12.AllItems; Title13.Text = Text(Today(); "dd-mm-yyyy"))

or

CountRows(Filter(Gallery12.AllItems; Title13.Text = Text(Today(); "dd-mm-yyyy")))

 

Best regards,

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.

View solution in original post

9 REPLIES 9
Super User
Super User

Re: count if value is current date

@BQC 

You will need to supply the field in your Gallery datasource for the formula, not the text label.

 

So:  CountIf(Gallery12.AllItems; YourDateField=Today())

 

Hope this is helpful

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
TimRohr
Level 10

Re: count if value is current date

Also, if @RandyHayes 's suggestion doesn't get you there (for instance, if Title13 is really your field), look into the DateValue() function in case your information is being interpreted as a string rather than a date.

Community Support Team
Community Support Team

Re: count if value is current date

Hi @BQC ,

Which date format does the Today() function return? "mm/dd/yyyy" or "dd/mm/yyyy"?

Based on the formula that you provided, I think this issue may be related to the incompatible date format. The Text([@Title13]) formula returns "dd-mm-yyyy", but the Today() function returns "mm/dd/yyyy" or "dd/mm/yyyy".

 

I have made a test on my side, please take a try with the following workaround:

CountIf(Gallery12.AllItems; Text(YourDateColumn, "mm/dd/yyyy") = Text(Today(),"mm/dd/yyyy"))

Note: The YourDateColumn represents the Date column in your data source, which binds to the Title13 Label control.

Or

CountRows(
Filter(Gallery12.AllItems; Text(YourDateColumn; "mm/dd/yyyy") = Text(Today(); "mm/dd/yyyy"))
)

Best regards,

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.
BQC
Level: Powered On

Re: count if value is current date

As you can see on the below picture, my datefield is title13 from the Gallery datasource.

image.png

So according to your solution, i think i have done what you mean (without success).

If i am mistaking, please let me know and thank you for your help!

Community Support Team
Community Support Team

Re: count if value is current date

Hi @BQC ,

Could you please share a bit more about the Filter formula you typed within your Gallery?

Which column does the Title13 control connect to? Could you please share a bit more about the Text proeprty of the Title13 control in your Gallery?

 

Based on the needs that you mentioned, I think the solution I provided could achieve your needs.

Please check if you have typed proepr Filter formula within the Items proeprty of the Gallery.

 

Best regards,

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.
BQC
Level: Powered On

Re: count if value is current date

Hello @v-xida-msft 

The today() function returns in dd-mm-yyyy.

My (title13) also returns in the same format and both in - and not / as seperators. 

The CountIf functions gets error message, even if i use the column from the datasource 

CountIf(Gallery12.AllItems; Text(ForventetAfsluttet, "mm/dd/yyyy") = Text(Today(),"mm/dd/yyyy"))

Or just use the title13. 

Errors like "Unexpected character" "Expecting a boolean-value".

 

The Countrows functions is without error but returns 0 in value although in my dataset there is two assignments which are due today.

BQC
Level: Powered On

Re: count if value is current date

@v-xida-msft 

in my gallery i am using this sortbycolumns function in items

SortByColumns(Indkøberhåndtering;
              "Status"; 
              Descending;
              "ForventetAfsluttet";
              Descending
)

This is used to help sorting by two criterias as this is needed. 

My datasource which title13 is connected to is google sheets.

the text property for title13 is 

ThisItem.ForventetAfsluttet

As the column in the dataset is labelled ForventetAfsluttet.

I hope this the information you requested! Smiley Happy

 

Community Support Team
Community Support Team

Re: count if value is current date

Hi @BQC ,

I have made a test on my side, and don't have the issue that you mentioned. The screenshot as below:2.JPG

On your side, please take a try with the following formula:

CountIf(Gallery12.AllItems; Title13.Text = Text(Today(); "dd-mm-yyyy"))

or

CountRows(Filter(Gallery12.AllItems; Title13.Text = Text(Today(); "dd-mm-yyyy")))

 

Best regards,

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.

View solution in original post

BQC
Level: Powered On

Re: count if value is current date

Fantastic work! thank you. 

The Countif function worked like a charm now. 

I have an additional question, if that is ok.

Can it contain a sort function more? I would like it to also sort on body8 containing either "Ikke færdig" or "færdig".

As in the app, it should only count the amount which are due today and is labelled as "Ikke færdig".

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 266 members 5,606 guests
Please welcome our newest community members: