Forum Discussion

Mike22's avatar
Mike22
Helper III
8 years ago
Solved

Create Cycle inside tables to duplicate rows.

Hello Everyone,   I am trying to forecast leave for my organization and show the leave balance in the current leave cycle. I have the following columns Person ID Total Remain Staff daily cos...
  • Anonymous's avatar
    Anonymous
    8 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