Forum Discussion
simonchung
2 years agoFrequent Visitor
Using DAX to create a Calculated table
Hi, I would like to create a table from A to B, expand to 12 months with Start Date, Amount distributes evenly to 12 months, is it possible? thanks so much! Table A ID Start Date Amount ...
- 2 years ago
simonchung Hi Try it DAX
ExpandedTable = VAR MonthsToExpand = 12 VAR T1 = GENERATE( 'Table A', VAR StartDate = 'Table A'[Start Date] VAR AmountPerMonth = DIVIDE('Table A'[Amount], MonthsToExpand) VAR Dates = ADDCOLUMNS( GENERATESERIES(0, MonthsToExpand - 1, 1), "MonthDate", EDATE(StartDate, [Value]) ) RETURN SELECTCOLUMNS( Dates, "ID_Expanded", 'Table A'[ID], "Month", FORMAT([MonthDate], "MMM-yy"), "Amount1", AmountPerMonth ) ) RETURN SUMMARIZE( T1,[ID_Expanded],[Month],[Amount1])
DimaMD
2 years agoSolution Sage
simonchung Hi Try it DAX
ExpandedTable =
VAR MonthsToExpand = 12
VAR T1 =
GENERATE(
'Table A',
VAR StartDate = 'Table A'[Start Date]
VAR AmountPerMonth = DIVIDE('Table A'[Amount], MonthsToExpand)
VAR Dates = ADDCOLUMNS(
GENERATESERIES(0, MonthsToExpand - 1, 1),
"MonthDate", EDATE(StartDate, [Value])
)
RETURN
SELECTCOLUMNS(
Dates,
"ID_Expanded", 'Table A'[ID],
"Month", FORMAT([MonthDate], "MMM-yy"),
"Amount1", AmountPerMonth
)
)
RETURN
SUMMARIZE( T1,[ID_Expanded],[Month],[Amount1])- simonchung2 years agoFrequent Visitor
Exactly, thank you so so much!!