Hello Power Users,
I have a Collection which was created with "GroupBy" by Hospitals and Date of arrival:
Sample Data:
Hospital1, 29.01.2021, {Here I have nested table with patients who arrived on this day} 3patients
Hospital1, 30.01.2021, 2 patients
Hospital2, 28.01.2021, 1 patient
Hospital3, 27.01.2021, 2 patients
I want to count rows(patients) on each of those Results, so It look like this above (patients aren't counted yet) and Filter Collection if that Count is <>2 , only keeping results with 2 rows,
Example output:
Hospital1, 30.01.2021, 2 patients,
Hospital3, 27.01.2021, 2 patients,
That's one problem,
And then I want to check if those patients have a property which I have stored in my dropdown.selected, lets assume I have 10 possible properties and I want to only keep records with propertyId.1 and propertyId.2 and each of those properties cannot be duplicated. So If patient A have property1, Patient B can have only property2 or both patients need to be filtered out.
@WarrenBelz I saw that you solved similar case, but without using collections (pardon me, I've lost the topic), so maybe You could look at this one if not in a hurry 🙂 ?
Best Regards
Zbigniew
Solved! Go to Solution.
Sorry for the delay in response...are you still working on this?
For your formula, consider the following:
ClearCollect(colMainCollection,
Filter(
AddColumns(
GroupBy(
AddColumns(
Filter(
Visits,
'Visit Status' = Dropdown1_1.Selected.Value,
'TypeOfDisease'.name = Dropdown4.Selected.Name1 || 'TypeOfDisease'.name = Dropdown4.Selected.Name2,
'RandomUselessNumber' >= Value(TextInput1_2.Text) && 'RandomUselessNumber' <= Value(TextInput1_3.Text),
!StartsWith('AlreadyAdded'.'IdentifierOfDoctor', "Dr.")
),
"Hospital Name", 'Hospital'.'Name '
),
"Hospital Name", "DateOfPatientArrival", "AggregatedOrdersByHospitalNameAndDateOfPatientArrival"
),
"Number of records", CountRows(AggregatedOrdersByHospitalNameAndDateOfPatientArrival),
"_distinctRecords", CountRows(Distinct(AggregatedOrdersByHospitalNameAndDateOfPatientArrival, 'TypeOfDisease'.name))
),
('Number of records' = 2 ) && ('_distinctRecords' <> 2)
)
)
This will count the number of distinct Disease types. Then in the filter that takes out the number of records not equaling 2 (note, I've taken this into the formula here rather than reprocessing the collection with a removeIf) we just add in to check that the _distinctRecords is not 2.
This should give you what you need (if I am reading your descriptions right)
For your first issue:
Your formula should resemble this:
Filter(
AddColumns(
<yourCurrentGroupByFormulaHere>,
"_patientCount", CountRows(<yourPatientTableColumnFromYourGroupBy>)
),
_patientCount = 2
)
For the second (yes, you need no collections for this - and practically nothing else):
I would need to get a little clarification on your scenario. Can you explain more about the Dropdown and the items it would have and how that relates to the properties with the patient? Also, when you say "keep records with..." are you referring to the main group or the patients in the patient table in your group? I believe it is the last one, so, I'll also need to see your GroupBy formula that you have now (not sure if this is the one we worked on in your other thread).
Hey @RandyHayes
First point checked, based on the code you provided I was able to build working record counter and filter out the records:
This is text version of my working code:
(btw how to make gray background and format this code, like You did in the above example)
Sorry for the delay in response...are you still working on this?
For your formula, consider the following:
ClearCollect(colMainCollection,
Filter(
AddColumns(
GroupBy(
AddColumns(
Filter(
Visits,
'Visit Status' = Dropdown1_1.Selected.Value,
'TypeOfDisease'.name = Dropdown4.Selected.Name1 || 'TypeOfDisease'.name = Dropdown4.Selected.Name2,
'RandomUselessNumber' >= Value(TextInput1_2.Text) && 'RandomUselessNumber' <= Value(TextInput1_3.Text),
!StartsWith('AlreadyAdded'.'IdentifierOfDoctor', "Dr.")
),
"Hospital Name", 'Hospital'.'Name '
),
"Hospital Name", "DateOfPatientArrival", "AggregatedOrdersByHospitalNameAndDateOfPatientArrival"
),
"Number of records", CountRows(AggregatedOrdersByHospitalNameAndDateOfPatientArrival),
"_distinctRecords", CountRows(Distinct(AggregatedOrdersByHospitalNameAndDateOfPatientArrival, 'TypeOfDisease'.name))
),
('Number of records' = 2 ) && ('_distinctRecords' <> 2)
)
)
This will count the number of distinct Disease types. Then in the filter that takes out the number of records not equaling 2 (note, I've taken this into the formula here rather than reprocessing the collection with a removeIf) we just add in to check that the _distinctRecords is not 2.
This should give you what you need (if I am reading your descriptions right)
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 release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
User | Count |
---|---|
208 | |
98 | |
60 | |
51 | |
43 |
User | Count |
---|---|
257 | |
160 | |
85 | |
78 | |
57 |