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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / error in counting in c...
Power Apps
Answered

error in counting in collection in onstart property

(0) ShareShare
ReportReport
Posted on by 139

Excelent day for everyone. I am creating collections and then counting rows, I do all this in the onstart property.
It happens that when I use the collections it counts incorrectly but when I use the sharepoint list it counts correctly.
Why is this happening?
Is it correct that I create collections if I am going to work directly in onstart?
Can my code be reduced further?
Am I using the coalesce function correctly?

Concurrent(
ClearCollect(
colDBPartidasLecciones;
ShowColumns(
DBPartidasLecciones;
"ETAPA_x0020_DE_x0020_EJECUCI_x00";
"PARTIDA2"
)
);
ClearCollect(
colDBProyectos;
ShowColumns(
DBProyectos;
"Listadeproyectos"
)
);
ClearCollect(
col1;
Sort(
ListaTrabajadores;
ID;
SortOrder.Ascending
)
);
ClearCollect(
col2;
Sort(
ListaTrabajadores;
ID;
SortOrder.Descending
)
);
ClearCollect(
colListaContratistas;
ShowColumns(
ListaContratistas;
"Title"
)
);
ClearCollect(
colHorasHombres;
ShowColumns(
HorasHombre;
"Proyecto";
"MES";
"HorasMensuales"
)
);
ClearCollect(
colFlashReport;
FlashReport
);
ClearCollect(
colEntregablesAccidentes;
ShowColumns(
EntregablesAccidentes;
"Estado";
"Codigo"
)
);
ClearCollect(
colListaEntregablesAccidentes;
ShowColumns(
ListaEntregablesAccidents;
"Entregables"
)
);
ClearCollect(
colDBOPT;
ShowColumns(
DBOPT;
"Proyecto";
"Fecha"
)
)
);;
Concurrent(
ClearCollect(
colListaTrabajadores;
col1;
Filter(
col2;
Not(ID in col1.ID)
)
);
With(
{
wFilterAC: Filter(
colFlashReport;
((TipoAccidente = "Accidente Leve" || TipoAccidente = "Accidente Incapacitante") And FechaHora >= DateValue("01/01/2023"))
)
};
Coalesce(
Set(
varAcAm;
CountRows(
Filter(
wFilterAC;
Proyecto = "Amancae"
)
)
);
(Set(
varAcAq;
CountRows(
Filter(
wFilterAC;
Proyecto = "Aquilaria"
)
)
));
(Set(
varAcGar;
CountRows(
Filter(
wFilterAC;
Proyecto = "Gardenia"
)
)
));
(Set(
varAcSau;
CountRows(
Filter(
wFilterAC;
Proyecto = "Sauco"
)
)
))
)
);
With(
{
wFilterACOct: Filter(
colFlashReport;
((TipoAccidente = "Accidente Leve" || TipoAccidente = "Accidente Incapacitante") And FechaHora >= DateValue("01/10/2023"))
)
};
Coalesce(
Set(
varAcOctAm;
CountRows(
Filter(
wFilterACOct;
Proyecto = "Amancae"
)
)
);
(Set(
varAcOctAq;
CountRows(
Filter(
wFilterACOct;
Proyecto = "Aquilaria"
)
)
));
(Set(
varAcOctGar;
CountRows(
Filter(
wFilterACOct;
Proyecto = "Gardenia"
)
)
));
(Set(
varAcOctSau;
CountRows(
Filter(
wFilterACOct;
Proyecto = "Sauco"
)
)
))
)
);
With(
{
wFilterInc: Filter(
colFlashReport;
(TipoAccidente = "Incidente" And FechaHora >= DateValue("01/01/2023"))
)
};
Coalesce(
Set(
varInAm;
CountRows(
Filter(
wFilterInc;
Proyecto = "Amancae"
)
)
);
(Set(
varInAq;
CountRows(
Filter(
wFilterInc;
Proyecto = "Aquilaria"
)
)
));
(Set(
varInGar;
CountRows(
Filter(
wFilterInc;
Proyecto = "Gardenia"
)
)
));
(Set(
varInSau;
CountRows(
Filter(
wFilterInc;
Proyecto = "Sauco"
)
)
))
)
)
)

 

When I change colFlashReport to FlashReport, which is the file that is in sharepoint, it gives me the appropriate result.

very grateful for your support

Very grateful for your answers.

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    Hi @Daniel20 ,

    Firstly, if you are going to paste code of that volume, please use Format Text and post in a Text box (the </> icon at the top). I have parsed it in Notepad to show what it should look like below.
    However, your two issues relate to a very small part of this code and it is better for future reference to simply refer to those. The first issue is that Coalesce finds the first non-blank value, so I do not believe it is doing anything to add to your code here.
    The second issue is that probably FlashReport contains more records that your Delegation limit, so the collection will not contain all records, whereas the Delegable filter you have applied before CountRows using the List brings it down under this.

    Concurrent(
     ClearCollect(
     colDBPartidasLecciones;
     ShowColumns(
     DBPartidasLecciones;
     "ETAPA_x0020_DE_x0020_EJECUCI_x00";
     "PARTIDA2"
     )
     );
     ClearCollect(
     colDBProyectos;
     ShowColumns(
     DBProyectos;
     "Listadeproyectos"
     )
     );
     ClearCollect(
     col1;
     Sort(
     ListaTrabajadores;
     ID;
     SortOrder.Ascending
     )
     );
     ClearCollect(
     col2;
     Sort(
     ListaTrabajadores;
     ID;
     SortOrder.Descending
     )
     );
     ClearCollect(
     colListaContratistas;
     ShowColumns(
     ListaContratistas;
     "Title"
     )
     );
     ClearCollect(
     colHorasHombres;
     ShowColumns(
     HorasHombre;
     "Proyecto";
     "MES";
     "HorasMensuales"
     )
     ); 
     ClearCollect(
     colFlashReport;
     FlashReport
     );
     ClearCollect(
     colEntregablesAccidentes;
     ShowColumns(
     EntregablesAccidentes;
     "Estado";
     "Codigo"
     )
     );
     ClearCollect(
     colListaEntregablesAccidentes;
     ShowColumns(
     ListaEntregablesAccidents;
     "Entregables"
     )
     );
     ClearCollect(
     colDBOPT;
     ShowColumns(
     DBOPT;
     "Proyecto";
     "Fecha"
     )
     )
    );;
    Concurrent(
     ClearCollect(
     colListaTrabajadores;
     col1;
     Filter(
     col2;
     Not(ID in col1.ID)
     )
     );
     With(
     {
     wFilterAC: 
     Filter(
     colFlashReport;
     (
     (
     TipoAccidente = "Accidente Leve" || 
     TipoAccidente = "Accidente Incapacitante"
     ) And 
     FechaHora >= DateValue("01/01/2023")
     )
     )
     };
     Coalesce(
     Set(
     varAcAm;
     CountRows(
     Filter(
     wFilterAC;
     Proyecto = "Amancae"
     )
     )
     );
     (
     Set(
     varAcAq;
     CountRows(
     Filter(
     wFilterAC;
     Proyecto = "Aquilaria"
     )
     )
     )
     );
     (
     Set(
     varAcGar;
     CountRows(
     Filter(
     wFilterAC;
     Proyecto = "Gardenia"
     )
     )
     )
     );
     (
     Set(
     varAcSau;
     CountRows(
     Filter(
     wFilterAC;
     Proyecto = "Sauco"
     )
     )
     )
     )
     )
     );
     With(
     {
     wFilterACOct: 
     Filter(
     colFlashReport;
     (
     (
     TipoAccidente = "Accidente Leve" || 
     TipoAccidente = "Accidente Incapacitante"
     ) And 
     FechaHora >= DateValue("01/10/2023")
     )
     )
     };
     Coalesce(
     Set(
     varAcOctAm;
     CountRows(
     Filter(
     wFilterACOct;
     Proyecto = "Amancae"
     )
     )
     );
     (
     Set(
     varAcOctAq;
     CountRows(
     Filter(
     wFilterACOct;
     Proyecto = "Aquilaria"
     )
     )
     )
     );
     (
     Set(
     varAcOctGar;
     CountRows(
     Filter(
     wFilterACOct;
     Proyecto = "Gardenia"
     )
     )
     )
     );
     (
     Set(
     varAcOctSau;
     CountRows(
     Filter(
     wFilterACOct;
     Proyecto = "Sauco"
     )
     )
     )
     )
     )
     );
     With(
     {
     wFilterInc: 
     Filter(
     colFlashReport;
     (
     TipoAccidente = "Incidente" And 
     FechaHora >= DateValue("01/01/2023")
     )
     )
     };
     Coalesce(
     Set(
     varInAm;
     CountRows(
     Filter(
     wFilterInc;
     Proyecto = "Amancae"
     )
     )
     );
     (
     Set(
     varInAq;
     CountRows(
     Filter(
     wFilterInc;
     Proyecto = "Aquilaria"
     )
     )
     )
     );
     (
     Set(
     varInGar;
     CountRows(
     Filter(
     wFilterInc;
     Proyecto = "Gardenia"
     )
     )
     )
     );
     (
     Set(
     varInSau;
     CountRows(
     Filter(
     wFilterInc;
     Proyecto = "Sauco"
     )
     )
     )
     )
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Daniel20 Profile Picture
    139 on at

    very grateful for the response. You're right, I shouldn't have pasted all the code. Actually I don't think it has to do with the delegation since there are only 207 rows.

    The rest of the results come out correct except for one.

    With flashreport they give me the following results:

    Daniel20_3-1700354312491.png

     

    and with col flashreport they give me the following results:

    Daniel20_2-1700354264402.png

    This is the flashreport collection:

    Daniel20_4-1700354439293.png

    Another question, is it okay to work with such long codes in onstart? Do you recommend working in any other way?
    Thank you very much for taking the time to respond, for me you are an idol.

     

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard