Forum Discussion
Getting Totals by day with dynamic dates
- 4 years ago
I'm having trouble understanding the tie between the answer key and the data but would something like this help provided you have a source column for when the accounts activate and leave?? I'm assuming you have date table. ****[see sample at bottom called dimdate]
Accounts Active= VAR _startofperiod = MIN ( DimDate[Date] ) VAR _endofperiod = MAX ( DimDate[Date] ) VAR _threshold = sum(//revenue column goes here//) RETURN CALCULATE ( sum( Table1[#Accounts] ), Table1[//DateAdded//] <= _endofperiod, Table1[//revenue//]>=_thresholddate, Table1[//DateInactive//] > _endofperiod) ), REMOVEFILTERS ( DimDate ) ) ****If not, try this code for a default date table. Just click Table Tools / New Table and paste inDimDate = VAR MINYEAR = 2008 //or some other min year VAR MAXYEAR = 2021 VAR _DateTable = ADDCOLUMNS ( FILTER ( CALENDARAUTO( ), AND ( YEAR ( [DATE] ) >= MINYEAR, YEAR ( [DATE] ) <= MAXYEAR ) ), "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), "Year", YEAR ( [Date] ), "Monthnumber", FORMAT ( [Date], "MM" ), "YearMonthnumber", FORMAT ( [Date], "YYYYMM" ), "YearMonthtext", FORMAT ( [Date], "YYYYMM" ), "YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ), "MonthNameShort", FORMAT ( [Date], "mmm" ), "MonthNameLong", FORMAT ( [Date], "mmmm" ), "DayOfWeekNumber", WEEKDAY ( [Date] ), "DayOfWeek", FORMAT ( [Date], "dddd" ), "DayOfWeekShort", FORMAT ( [Date], "ddd" ), "Quarter", "QTR-" & FORMAT ( [Date], "Q" ), "YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ), "YearQuarterNumber", Year([Date])*4 + QUARTER([Date]), "HalfYear", YEAR([Date])&" H"&ROUNDUP(MONTH([Date])/6,0), "LastImport", max(Table2[Max Date]) ) RETURN _DateTable - Anonymous4 years ago
Hi evest ,
It's hard to achieve the look you want in the matrix. I have tried another way, please see if it helps.
Create measures.
Year_2021 = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[date].[Year]=SELECTEDVALUE('Table'[date].[Year])))month_1 = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[date].[MonthNo]=SELECTEDVALUE('Table'[date].[MonthNo])))Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 4 years ago
This works but now it wont show my previous months value. Here is my dax
Prev Month Premium =CALCULATE('Jan/Feb2022(Active_Plans___Estimated_Premiu)'[TTL Prem2022],PREVIOUSMONTH('Jan/Feb2022(Active_Plans___Estimated_Premiu)'[Effective Date]))
Can you share an example of what (1) would look like?
This is what it should look like. The totals will include each day of the month where the day is missing monthly revenue and monthly premium in these columns the value is 0 or null. This is for 2021 but when I run the report the dates should adjust to 2022 dates. The dates you are looking at are the dates the report is run for that month.
| Office | Count as of 1/11/2021 | Count as of 2/25/2021 | Count as of 3/8/2021 | Count as of4/27/2021 | Count as of 5/10/2021 | Count as of6/23/2021 | Count as of7/12/2021 | Count as of 8/19/2021 | Count as of 9/15/2021 | Count as of 11/18/2021 | Count as of 12/14/2021 |
| a | 30 | 46 | 35 | 22 | 23 | 20 | 22 | 32 | 27 | 27 | 38 |
| b | 6 | 6 | 0 | 7 | 5 | 8 | 1 | 1 | 0 | 2 | 3 |
| c | 264 | 134 | 113 | 108 | 113 | 83 | 41 | 37 | 51 | 76 | 122 |
| d | 52 | 52 | 51 | 53 | |||||||
| e | 37 | 34 | 31 | 38 | 30 | 39 | 39 | 36 | 90 | 43 | 44 |
| f | 31 | 19 | 19 | 20 | 21 | 23 | 22 | 21 | 21 | 24 | 25 |
| g | 2 | 0 | 1 | 8 | 0 | 6 | 6 | 9 | 11 | 26 | 21 |
| h | 14 | 14 | 11 | 13 | 17 | 21 | 12 | 14 | 11 | 20 | 25 |
| i | 30 | 30 | 29 | 24 | 25 | 25 | 28 | 29 | 36 | 35 | 36 |
| j | 8 | 6 | 2 | 18 | 4 | 5 | 4 | 1 | 1 | 3 | 1 |
| k | 66 | 58 | 59 | 74 | 78 | 62 | 61 | 74 | 74 | 63 | 91 |
| l | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 | 3 | 3 | 3 |
| m | 29 | 59 | 37 | 59 | 71 | 64 | 57 | 69 | 77 | 73 | 153 |
| n | 5 | 5 | 5 | 7 | 7 | 7 | 7 | 7 | 7 | 7 | 7 |
| o | 4 | 7 | 6 | 8 | 24 | 7 | 11 | 16 | 14 | 22 | 11 |
| p | 935 | 1283 | 1210 | 1235 | 1278 | 1266 | 1159 | 1206 | 1218 | 1210 | 1260 |