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?
I did not get a solution from this forum. So I will rephrase my question. What I need to show in the matrix is pre aggregation for the year 2021 and monthly totals for 2022.
| Total for entire 2021 | 2022 | |
| January | Feburary | |
| 123,690 | 150 | 678 |