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

Return Count from Data Source

I cannot figure out how to get powerapps to return a count of days within the current month or year from my data source.  Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Return Count from Data Source

You can also use the current date (obtained via the Today function) for that, the values don't have to come from a (fixed) source. This way, anytime the user opens your app, the value of "today" will be updated and the number of days in the current month will be reflected:

"Days in the current month: " &
    DateDiff(
        Date(Year(Today()), Month(Today()), 1),
        Date(Year(Today()), Month(Today()) + 1, 1),
        Days)

View solution in original post

3 REPLIES 3
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Return Count from Data Source

You can use the DateDiff function to do that. Create a date for the 1st day of the month you want to have the number of days, and another date for the 1st of the following month, and you should get that.

 

For example, in this app snippet below 

ForumPost-App.png

 

The formula for the text box that depends on the dropdown lists is the following:

"Days in month: " &
    DateDiff(
        Date(Value(Dropdown1.Selected.Value), Value(Dropdown2.Selected.Value), 1),
        Date(Value(Dropdown1.Selected.Value), Value(Dropdown2.Selected.Value) + 1, 1),
        Days)

Notice that when this formula also works for December (if you pass the value 13 for the Date function it will create a date on January of the following year).

 

In your case, you would need to replace the parameters for the Date function from the dropdown to the value you have from your data source.

mdziados
Level: Powered On

Re: Return Count from Data Source

I would have to update this every month or create a different textbox to show monthly sums for each month with this wouldn't I? Is there anyway to do it where it will automatically reset at the beginning of each month?
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Return Count from Data Source

You can also use the current date (obtained via the Today function) for that, the values don't have to come from a (fixed) source. This way, anytime the user opens your app, the value of "today" will be updated and the number of days in the current month will be reflected:

"Days in the current month: " &
    DateDiff(
        Date(Year(Today()), Month(Today()), 1),
        Date(Year(Today()), Month(Today()) + 1, 1),
        Days)

View solution in original post

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 (Last 30 Days)
Users online (6,004)