Forum Discussion
Anonymous
5 years agoNot applicable
conditional sum in a filtered table
Hi all
from a DB, here the link, I made this summarize funcion:
Pick_PKuph = summarize(filter(PICK, PICK[TIPO]= "PK"),PICK[ORA], PICK[GIORNO], "tot", sum(PICK[TOTALE]), "Prel", sum(PICK[PRELEVATO]), "ops nr", DISTINCTCOUNT(PICK[MATRICOLA]), "Contenitori", count(PICK[CONTENITORE]))
How can we make a conditional sum of TOT while filtering:
- the sum of TOT for each ORA, by each MATRICOLA, must be > 7?
Here the result reached:
| Nt tot | 308 | 479 | 833 | 647 | 648 | 379 | 117 | 40 | 37 | 80 | 257 | 445 | 452 | 65 | 380 | 131 | |
| Nr ops | 6 | 13 | 18 | 19 | 14 | 12 | 4 | 3 | 1 | 3 | 7 | 9 | 8 | 3 | 12 | 9 |
In the attached link all data are shown and also an example of pivot table to achive the output
Thanks for help
Nr Ops := var a = SUMMARIZE(PICK,PICK[ORA],PICK[MATRICOLA],"Tot",sum(PICK[TOTALE])) return COUNTROWS(filter(a,[Tot]>7)) Nt Tot := var a = SUMMARIZE(PICK,PICK[ORA],PICK[MATRICOLA],"Tot",sum(PICK[TOTALE])) return SUMX(filter(a,[Tot]>7),[Tot])I did the PK filter on page level but you can add it to the measures if you want.
1 Reply
- lbendlinSuper User
Nr Ops := var a = SUMMARIZE(PICK,PICK[ORA],PICK[MATRICOLA],"Tot",sum(PICK[TOTALE])) return COUNTROWS(filter(a,[Tot]>7)) Nt Tot := var a = SUMMARIZE(PICK,PICK[ORA],PICK[MATRICOLA],"Tot",sum(PICK[TOTALE])) return SUMX(filter(a,[Tot]>7),[Tot])I did the PK filter on page level but you can add it to the measures if you want.