Forum Discussion
Create Cycle inside tables to duplicate rows.
- Anonymous8 years ago
Hi Mike22,
>>As you can see it is increasing 2.5 every month but it is giving me the full list of all days of the month. Is it possible to have one value for every month only?
I think it is easy to achieve, you only need to add filter function to choose which day you want to keep.
Expand = VAR _start = FIRSTDATE ( 'Sample'[Current Month] ) VAR _calendar = CALENDAR ( _start, DATE ( YEAR ( _start ), 3, 30 ) ) RETURN FILTER ( SELECTCOLUMNS ( FILTER ( ADDCOLUMNS ( CROSSJOIN ( 'Sample', _calendar ), "Rolling", [Total Remain] + 2.5 * DATEDIFF ( [Current Month], [Date], MONTH ) ), [Rolling] <= [Staff daily cost] + 2.5 ), "Person ID", [Person ID], "Rolling", [Rolling], "Staff daily cost", [Staff daily cost], "Date", [Date] ), DAY ( [Date] ) = 10 )You can also modify 'date' column to year month, then use distinct function to filter duplicate records.
Regards,
Xiaoxin Sheng
Hi Mike22,
>>As you can see it is increasing 2.5 every month but it is giving me the full list of all days of the month. Is it possible to have one value for every month only?
I think it is easy to achieve, you only need to add filter function to choose which day you want to keep.
Expand =
VAR _start =
FIRSTDATE ( 'Sample'[Current Month] )
VAR _calendar =
CALENDAR ( _start, DATE ( YEAR ( _start ), 3, 30 ) )
RETURN
FILTER (
SELECTCOLUMNS (
FILTER (
ADDCOLUMNS (
CROSSJOIN ( 'Sample', _calendar ),
"Rolling", [Total Remain]
+ 2.5 * DATEDIFF ( [Current Month], [Date], MONTH )
),
[Rolling]
<= [Staff daily cost] + 2.5
),
"Person ID", [Person ID],
"Rolling", [Rolling],
"Staff daily cost", [Staff daily cost],
"Date", [Date]
),
DAY ( [Date] ) = 10
)
You can also modify 'date' column to year month, then use distinct function to filter duplicate records.
Regards,
Xiaoxin Sheng
Anonymous
This worked perfectly. Thank you so much for your help.