web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter Collection rows...
Power Apps
Unanswered

Filter Collection rows by Month and update variables

(0) ShareShare
ReportReport
Posted on by 62

I've got a list of items created through the year and need to produce an Excel report split in to quarters with a an entry against 5 questions for each month. At the end of FY Q1 (Apr - Jun) I need to provide the 5 data points for each of the 3 months.

 

I have the data in a SharePoint list and based on the date the record was entered there are 3 SharePoint columns, 'Month_Created', 'Quarter_Created' and 'Year_Created'. I use 2 drops downs for the Year and the Quarter to filter the gallery so only the records for that timeframe are returned. (the use of the gallery may be redundant but it allows me to view the results). This all works fine.

 

I then create a collection based on the same filter using the following code against a button.

ClearCollect(
colADRReport,Filter(
SP-List,Quarter_Record_Created=Dropdown4.Selected.Result&&'Year Record Created'=Dropdown5.Selected.Result&&Month_Record_Created=Dropdown5_1.Selected.Result
)
);

 

And from that collection populate some variables that I can then use in the report, again in the same button code as above. This gives me the results I need for the total quarter, but how do I break those results into additional variables that provide the date for each of the months?

 

Set(varUniqueREF,CountRows(Distinct(colADRReport,Ref_Number)));
Set(varApproval,CountIf(colADRReport,Approval_Given.Value="Yes"));
Set(varRetained,CountIf(colADRReport,Retained.Value="Yes"));
Set(varExtracted,CountIf(colADRReport,Extracted.Value="Yes"));
Set(varTurnaroundTime,Average(colADRReport,Time_Held));
Set(varCountOver24,CountIf(Filter(colADRReport,Retained.Value="Yes"),Time_Held>24));
Set(varReplacementOffered,CountIf(colADRReport,Find("Yes",Replacement_Offered.Value)>0));
Set(varReplacementAccepted,CountIf(colADRReport,Replacement_Accepted.Value="Yes"));

 

I add a 3rd dropdown for the 'Month_Created' it works and gives me the results for the month, but I need to have one command linked to a button that will create the results for each month in the selected quarter.

 

I know some kind of IF statement or Loop is needed to work through the collection containing the specific quarter and based on the value of the 'Month_Created' populate new variables that relate to each month, such as 'varAprUniqueRef' and 'varMayUniqueRef' etc.

Q1 - Apr-Jun

Q2 - Jul-Sep

Q3 - Oct-Dec

Q4 - Jan-Mar

 

Can someone provide some pointers on how I would go about this?

 

Many thanks in advance.

 

TC

Categories:
I have the same question (0)
  • BrianS Profile Picture
    2,407 Super User 2024 Season 1 on at
    Re: Filter Collection rows by Month and update variables

    Just a question - since you are aiming to get an Excel report from this, wouldn't it be easier to use Power Query in Excel to massage your data?

  • ThomasRConnor Profile Picture
    62 on at
    Re: Filter Collection rows by Month and update variables

    I hadn't thought of that (but I will take a look) as I ideally need this to be as hands-off as possible as the completed spreadsheet is emailed to an external recipient for compliance reasons on a Quarterly basis.

  • jaytavare18 Profile Picture
    6 on at
    Re: Filter Collection rows by Month and update variables

    Facing the same issue for past 2 months,

    ex:- SharePoint lists is having data of one year (12 months ) and when  we filter gallery from jan 2022 to dec 2022 and export to csv it should create 12 .csv files for each months, facing issue with creating more than 1 .csv file. So if you have found any solution please share it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 836 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 231 Super User 2025 Season 2

Last 30 days Overall leaderboard