Forum Discussion
tonyclifton
Helper III
2 years agoCount Products over time dealing with two date fields
Hello community, I need to calculated the count of products over time (months for now, maybe with daily accuracy). I want to show the increase or decrease of products based on when they were "adde...
- 2 years ago
tried it .
did work from my side . ( change my table to query2 , since i already have a table called exp_table)
ok i think i know the problem you are encountering .
change the code to this :
count of active products per day new = var calendar_per_product = FILTER( GENERATE( all(Query2[product]), var pr = Query2[product] var createddate = SELECTCOLUMNS(FILTER(Query2,Query2[product] = pr),"createddate",Query2[createddate]) var enddate = SELECTCOLUMNS(FILTER(Query2,Query2[product] = pr),"enddate",Query2[enddate]) return CALENDAR( if( ISBLANK(createddate) , DATEVALUE("2024-01-01"),createddate) , if( ISBLANK(enddate) , DATEVALUE("2024-12-31"),enddate) ) ), NOT ISBLANK(Query2[product]) ) var gds = GROUPBY( calendar_per_product, [Date], "c", countx(CURRENTGROUP() , DISTINCTCOUNT(Query2[product])) ) var res= MAXX( FILTER(gds,[Date] in VALUES(dimdate[Date])), [c]) return res
Daniel29195
Community Champion
2 years agofor date, you should filter from dimdate and not createddate .
because the code works base on the dimdate .
tonyclifton
Helper III
2 years agoI agree with dimdate but what about filtering by other columns of the original table like Plant for example?
- Daniel291952 years ago
Community Champion
i cant tell, since i dont have an idea how the model is structured.
but i assume it should work, if you have plant column that already filters the data .