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

Filter Collection rows by Month and update variables

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

2 REPLIES 2
BrianS
Super User
Super User

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
Frequent Visitor

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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,785)