Forum Discussion
wllmc
7 years agoNew Member
Variables
Hi, I am looking for a way to add date as variables in the tables created. I have a few more other tables that are alike and want to avoid having to go into each table to update the dates. ABC_SU...
- 7 years ago
Try putting them into a measure then using the measure in the table creation maybe?
Start Date = DATE(2017,1,1)
End Date = DATE(2017,3,31)
ABC_SUMM_US_LY = CALCULATETABLE ( SUMMARIZECOLUMNS ( ABC_SUMM[SERV_NAME], "TTL CONT EX OH", SUM ( ABC_SUMM[TTL CONT EX OH] ), "TTL REV", SUM ( ABC_SUMM[TTL REV] ) ), ABC_SUMM[SERV_NAME] = "US", DATESBETWEEN ( ABC_SUMM[MONTHYEAR], [Start Date], [End Date] ) )ABC_SUMM_US_TY = CALCULATETABLE ( SUMMARIZECOLUMNS ( ABC_SUMM[SERV_NAME], "TTL CONT EX OH", SUM ( ABC_SUMM[TTL CONT EX OH] ), "TTL REV", SUM ( ABC_SUMM[TTL REV] ) ), ABC_SUMM[SERV_NAME] = "US", DATESBETWEEN ( ABC_SUMM[MONTHYEAR], [Start Date], [End Date] ) )
Cmcmahan
7 years agoResident Rockstar
Ahh, see I read that as he has multiple tables and the only thing he wants to change between tables is the date range. If he's using the same date multiple times, then maybe set it up as a measure, but I'm still steadfastly against creating a ton of random tables when you can just aggregate on the fly and in context with your visuals.
jdbuchanan71
7 years agoSuper User
If we are just looking for an easier way to create the tables one at a time putting the dates as variables in the front is a bit better.
ABC_SUMM_US_LY =
VAR StartDate = DATE ( 2017, 1, 1 )
VAR ENdDate = DATE ( 2017, 3, 31 )
RETURN
CALCULATETABLE (
SUMMARIZECOLUMNS (
ABC_SUMM[SERV_NAME],
"TTL CONT EX OH", SUM ( ABC_SUMM[TTL CONT EX OH] ),
"TTL REV", SUM ( ABC_SUMM[TTL REV] )
),
ABC_SUMM[SERV_NAME] = "US",
DATESBETWEEN ( ABC_SUMM[MONTHYEAR], StartDate, EndDate )
)