by day
1 Topic12 Year Min/Max for running total
Hello, I am using a running total measure to calculate the current month, the prev month, and the same month last year. The challenging part is creating the Range for the past 12 months. How can I calculate the 12 month min and the 12 month max? Here are my measures for the current and previous month: Current = VAR _day = SELECTEDVALUE(Dates2[Day Number]) VAR _sum = CALCULATE(SUM(Table[Volume]), Dates[Day Number] = _day) RETURN IF(ISBLANK(_sum), BLANK(), CALCULATE( SUM(Table[Volume]), FILTER( ALLSELECTED(Dates[Day Number]), ISONORAFTER(Dates[Day Number], MAX(Dates[Day Number]), DESC) && Dates[Day Number] <= _day ) )) LastMonth = VAR _day = SELECTEDVALUE(Dates2[Day Number]) VAR _month = SELECTEDVALUE(Dates[PrevMonthYearDate]) VAR _sum = CALCULATE(SUM(Table[Volume]), ALL(Dates), Dates[Day Number] = _day && Dates[MonthYearDate] = _month) RETURN IF(ISBLANK(_sum), BLANK(), CALCULATE( SUM(Table[Volume]), FILTER( ALL(Dates), ISONORAFTER(Dates[Day Number], MAX(Dates[Day Number]), DESC) && Dates[Day Number] <= _day && Dates[MonthYearDate] = _month ) )) The dataset is simple. I use 3 tables, the Data table with Dates, Volumes, and Locations. The other 2 tables are Date tables. I use 2 date tables because the amount of days in the selected month may not be complete or will have less days than the previous month so the days after would not show. (The yellow line after the end of the blue line won't show if I didn't use 2 date tables.)Solved1.1KViews2likes5Comments