Forum Discussion
how to repeat the rows in a Datatable based on a column value
- 7 years ago
You may refer to steps below:
Firstly, click Modeling-> New Table, repeat current rows using DAX below:
Table = UNION ( Table1, Table1, Table1, Table1, Table1, Table1, Table1, Table1, Table1, Table1, Table1, Table1 )Secondly, create a calendar table which contains a series of date which is end of month:
Calendar = UNION ( ROW ( "EOMDate", EOMONTH ( "02/28/2018", 0 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 1 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 2 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 3 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 4 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 5 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 6 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 7 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 8 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 9 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 10 ) ), ROW ( "EOMDate", EOMONTH ( "02/28/2018", 11 ) ) )Finally, generate the result table using DAX below:
Result = DISTINCT ( SELECTCOLUMNS ( CROSSJOIN ( 'Table', 'Calendar' ), "CLIENT_POLICY_NUMBER", 'Table'[CLIENT_POLICY_NUMBER], "StartDate", 'Table'[StartDate], "EndDate", 'Table'[EndDate], "PolicyYear", 'Table'[PolicyYear], "InforceDate", 'Table'[InforceDate], "CancelDate", 'Table'[CancelDate], "INSURED", 'Table'[INSURED], "DOM_STA", 'Table'[DOM_STA], "PROGRAM", 'Table'[PROGRAM], "PRODUCT", 'Table'[PRODUCT], "Company", 'Table'[COMPANY], "MGA_NAM", 'Table'[MGA_NAM], "Total_Poli", 'Table'[Total_Poli], "ProfitCen", 'Table'[ProfitCen], "EOMDate", 'Calendar'[EOMDate] ) )Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You may refer to steps below:
Firstly, click Modeling-> New Table, repeat current rows using DAX below:
Table =
UNION (
Table1,
Table1,
Table1,
Table1,
Table1,
Table1,
Table1,
Table1,
Table1,
Table1,
Table1,
Table1
)
Secondly, create a calendar table which contains a series of date which is end of month:
Calendar =
UNION (
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 0 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 1 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 2 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 3 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 4 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 5 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 6 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 7 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 8 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 9 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 10 ) ),
ROW ( "EOMDate", EOMONTH ( "02/28/2018", 11 ) )
)
Finally, generate the result table using DAX below:
Result =
DISTINCT (
SELECTCOLUMNS (
CROSSJOIN ( 'Table', 'Calendar' ),
"CLIENT_POLICY_NUMBER", 'Table'[CLIENT_POLICY_NUMBER],
"StartDate", 'Table'[StartDate],
"EndDate", 'Table'[EndDate],
"PolicyYear", 'Table'[PolicyYear],
"InforceDate", 'Table'[InforceDate],
"CancelDate", 'Table'[CancelDate],
"INSURED", 'Table'[INSURED],
"DOM_STA", 'Table'[DOM_STA],
"PROGRAM", 'Table'[PROGRAM],
"PRODUCT", 'Table'[PRODUCT],
"Company", 'Table'[COMPANY],
"MGA_NAM", 'Table'[MGA_NAM],
"Total_Poli", 'Table'[Total_Poli],
"ProfitCen", 'Table'[ProfitCen],
"EOMDate", 'Calendar'[EOMDate]
)
)
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.