Forum Discussion
Distributing values between start and end dates and get the cumulative
- 6 years ago
Hi MAbdelRazik ,
Create a table as below:
Table 2 = CALENDAR(MIN('Table'[Start]),MAX('Table'[End]))Then create 2 measures as below :
_Value = var _table=ADDCOLUMNS('Table 2',"value",CALCULATE(MAX('Table'[Column]),FILTER(ALL('Table'),'Table'[Start]<='Table 2'[Date]&&'Table'[End]>='Table 2'[Date]))) Return MAXX(_table,[value])_Cumulative value = SUMX(FILTER(ALL('Table 2'),'Table 2'[Date]<=MAX('Table 2'[Date])),'Table 2'[_Value])And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
MAbdelRazik So did you create a table for breaking things out or a measure? If a table, create a calculated column. If a measure, do measure aggregation and add a column using ADDCOLUMNS then filter down to the current in context date. The column calculation goes something like:
Column = SUMX(FILTER('Table',[Date]<=EARLIER([Date]),[Value])
Did you use something like Open Tickets to break things out?
https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364#M147
Greg_Deckler So, I had the one table with StartDate, EndDate and valuePerDay. I will call this Data_table.
I created a table that has dates and I will call this DateSTable. I created a measure using this code:
- Greg_Deckler6 years ago
Community Champion
MAbdelRazik OK, if that is your measure, we will go the measure route. So:
Cumulative Measure = VAR __Date = MAX('DateSTable'[Date]) VAR __Table = FILTER(ALL('DateSTable'[Date]),[Date]<=__Date) VAR __Table1 = ADDCOLUMNS( __Table, "PerDay",SUMX(FILTER(Data_Table,Date_Table[StartDate]<=[Date]&& Data_Table[EndDate] >=[Date]) ) VAR __Table2 = ADDCOLUMNS( __Table1, "Cumulative",SUMX(FILTER(__Table1,[Date]<=EARLIER([Date])),[PerDay]) ) RETURN MAXX(FILTER(__Table2,[Date]=__Date),[Cumulative)