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]))
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.
This works but now it wont show my previous months value. Here is my dax
- Anonymous4 years agoNot applicable
Hi evest ,
Please have a try.
Create a column firstly.
Month_c = TOTALMTD(MAX('Table'[date].[MonthNo]),'Table'[date],FILTER(ALL('Table'),[Date].[MonthNo]=EARLIER('Table'[date].[MonthNo])))Then create a measure.
sum_ = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[Month_c]<=SELECTEDVALUE('Table'[Month_c])&&'Table'[date].[Year]=SELECTEDVALUE('Table'[date].[Year])))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.