Forum Discussion
Split monthly values to daily values
- 6 years ago
Then this scenario will be much more complicated because the date needs to mutiply the product number.
my solution is a little complicated.
1. add month column into your datetime table
2. Then create a new table
new table = VAR TBL1=ADDCOLUMNS(SUMMARIZE(DATETIME,DATETIME[Date]),"_month",MAXX(FILTER('DATETIME','DATETIME'[Date]=EARLIER(DATETIME[Date])),'DATETIME'[Month])) VAR TBL2=ADDCOLUMNS(SUMMARIZE('Table','Table'[Item],'Table'[Month],'Table'[VALUE]),"_month",MAXX(FILTER('Table','Table'[Month]=EARLIER('Table'[Month])),'Table'[Month])) RETURN NATURALLEFTOUTERJOIN(TBL1,TBL2)3. create a new column in the new table.
average = var day= CALCULATE(DISTINCTCOUNT('new table'[Date]),FILTER('new table','new table'[_month]=EARLIER('new table'[_month]))) return 'new table'[VALUE]/dayI am not sure if this is the best solution for you. Let's see if anyone else can provide a better one.
Hope this is helpful.
Thanks Ryan!
is the'result' table the date table?
When I add a column:
What's the month value in your table?
Why I use FORMAT('Date'[Date],"mmmm"))? It's because your sample data was May, June. That transfer date type to long month name.
In my result table, I change the date to long month name , then lookup for May and June.
Please make sure these two columns are the same data type.
'DemandForecastEntries'[ForecastStartDate],FORMAT('Date'[Date],"mmmm")
- iiomarioii6 years ago
Helper II
amitchandak Unfortunately no.
I know why your approach didnt work now.
I have multiple values for each date with different ItemNumbers:
Date Item number Value June 001 600 June 002 300 July .... ... So my result should look like:
Date Item number Value 1 June 001 20 1 June 002 10 2 June 001 20 2 June 002 10 ... ... ... I think I just have to add a second criteria into LOOKUPVALUE?
Thank you!
- ryan_mayu6 years ago
Super User
Then this scenario will be much more complicated because the date needs to mutiply the product number.
my solution is a little complicated.
1. add month column into your datetime table
2. Then create a new table
new table = VAR TBL1=ADDCOLUMNS(SUMMARIZE(DATETIME,DATETIME[Date]),"_month",MAXX(FILTER('DATETIME','DATETIME'[Date]=EARLIER(DATETIME[Date])),'DATETIME'[Month])) VAR TBL2=ADDCOLUMNS(SUMMARIZE('Table','Table'[Item],'Table'[Month],'Table'[VALUE]),"_month",MAXX(FILTER('Table','Table'[Month]=EARLIER('Table'[Month])),'Table'[Month])) RETURN NATURALLEFTOUTERJOIN(TBL1,TBL2)3. create a new column in the new table.
average = var day= CALCULATE(DISTINCTCOUNT('new table'[Date]),FILTER('new table','new table'[_month]=EARLIER('new table'[_month]))) return 'new table'[VALUE]/dayI am not sure if this is the best solution for you. Let's see if anyone else can provide a better one.
Hope this is helpful.
- iiomarioii6 years ago
Helper II
Thank you Ryan. This was very helpful. I am still trying to understand the complete formula but it works actually.
But I am getting the right values just for one month:
But I need the same average values for all other months:
Do you have a solution for this?
Thank you!