
Hey there,
I have an app where I need to have a gallery with the following;
It need to count the rows based on a dropdown with the order number, the company name and between 2 selected dates. I almost got it working like it should, but it is somehow counting wrong. Hopefully someone here can spot the mistake.
This is how it looks (aantal = count):
But when I select only the 21-06-2022 one, I get the following result (12), as also shown in the picture above:
But when I use countrows function on the collection with the same filter, I get 13 (the answer is actually 13, so the 12 is wrong)
Code for the result of 13;
CountRows(
Filter(colCombined;
Order0 = Dropdown_Order_1.Selected.Result &&
Geopperd = "TRUE" &&
// Geopperddatum is the date in the collection
(DateValue(Geopperddatum)>=StartDatumPicker.SelectedDate && DateValue(Geopperddatum)<=EindDatumPicker.SelectedDate)
)
)
Code of the gallery which is a bit more complex, but uses the exact same filters. There is a dropdown to change between: "Geopperd, Gemonteerd and Opgeleverd", but for now we can focus on just "Geopperd", as I used that for the example
SortByColumns(
AddColumns(
GroupBy(
AddColumns(
Filter(
Sort(colCombined; ID; Descending);
If(
Dropdown_MontageOptie.Selected.Value = "Geopperd";
Geopperd = "TRUE" && (DateValue(Geopperddatum)>=StartDatumPicker.SelectedDate && DateValue(Geopperddatum)<=EindDatumPicker.SelectedDate);
Dropdown_MontageOptie.Selected.Value = "Gemonteerd";
Gemonteerd = "TRUE" && (DateValue(Gemonteerddatum)>=StartDatumPicker.SelectedDate && DateValue(Gemonteerddatum)<=EindDatumPicker.SelectedDate);
Dropdown_MontageOptie.Selected.Value = "Opgeleverd";
Opgeleverd = "TRUE" && (DateValue(Opgeleverddatum)>=StartDatumPicker.SelectedDate && DateValue(Opgeleverddatum)<=EindDatumPicker.SelectedDate)
) &&
Order0 = Dropdown_Order_1.SelectedText.Result &&
(bedrijfNaam = MontageFirma || bedrijfNaam = MontageFirma2)
);
"opgeleverdDatumSamengesteld";
Opgeleverddatum;
"opgeleverdSamengesteld";
Opgeleverd;
"montageFirma";
MontageFirma;
"montageFirma2";
MontageFirma2;
"orderNummer";
Order0
);
// Group by gedeelte
"opgeleverdDatumSamengesteld";
"montageFirma";
"montageFirma2";
"orderNummer";
"sumOpgeleverd"
);
// 2e Add columns formule
"sumOpgeleverdCount";
Sum(
sumOpgeleverd;
If(
Dropdown_MontageOptie.Selected.Value = "Geopperd";
Geopperd = "TRUE" && (DateValue(Geopperddatum)>=StartDatumPicker.SelectedDate && DateValue(Geopperddatum)<=EindDatumPicker.SelectedDate);
Dropdown_MontageOptie.Selected.Value = "Gemonteerd";
Gemonteerd = "TRUE" && (DateValue(Gemonteerddatum)>=StartDatumPicker.SelectedDate && DateValue(Gemonteerddatum)<=EindDatumPicker.SelectedDate);
Dropdown_MontageOptie.Selected.Value = "Opgeleverd";
Opgeleverd = "TRUE" && (DateValue(Opgeleverddatum)>=StartDatumPicker.SelectedDate && DateValue(Opgeleverddatum)<=EindDatumPicker.SelectedDate)
) &&
Order0 = Dropdown_Order_1.SelectedText.Result &&
(bedrijfNaam = MontageFirma || bedrijfNaam = MontageFirma2)
)
);
// SortBy
"opgeleverdDatumSamengesteld";
Descending
)
I've been stuck on this for a while, so any help is much appreciated! If there is an easier way to do this with less code, also let me know 🙂 (This also takes quite some time to calculate)
To get a count of rows that matches what is shown in the gallery, do your CountRows() on the gallery itself:
CountRows(myGalleryName.AllItems)
Hope that helps,
Bryan