Forum Discussion

UK06B1's avatar
UK06B1
Helper II
5 years ago
Solved

Calculating Month value based on Cumulative Weekly Data with 2 variables

Hello  I need to add a column to my data which returns the month movement for a sepcified filter. The data is in the screen shot below, for example the new column would have 30.47 for line 1 (Week 1...
  • amitchandak's avatar
    5 years ago

    UK06B1 , Based on what I got so far,

     

    You can new column that give you weekly values 

    new column =
    var _max = maxx(filter(Table, [Employee Name] = earlier([employee name]) && [Week ending] <earlier([Week ending])), [week ending])
    return
    [Number of hours] - maxx(filter(Table, [Employee Name] = earlier([employee name]) && [Week ending] =_max), [Number of hours])

     

    You can distribute this table with help date table if needed

     

    new column =
    var _max = maxx(filter(Table, [Employee Name] = earlier([employee name]) && [Week ending] <earlier([Week ending])), [week ending])
    return
    [Number of hours] - maxx(filter(Table, [Employee Name] = earlier([employee name]) && [Week ending] =_max), [Number of hours])

     

    How to divide/distribute values between start date or end date or count days across months/days: https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-or-end-date/ba-p/1503785

     

  • v-jingzhang's avatar
    5 years ago

    Hi UK06B1 

     

    Here is a method of calculated column.

    Month Movement =
    VAR __lastWeekEnding = 'Table (2)'[Week Ending] - 7
    RETURN
        'Table (2)'[Number of Hours]
            - MAXX (
                FILTER (
                    'Table (2)',
                    'Table (2)'[Name] = EARLIER ( 'Table (2)'[Name] )
                        && 'Table (2)'[Time Type] = EARLIER ( 'Table (2)'[Time Type] )
                        && 'Table (2)'[Week Ending] = __lastWeekEnding
                ),
                'Table (2)'[Number of Hours]
            )
    

     

     

    Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as the solution to help other members find it.