Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Previous Month on Calculated Column

Hi everyone,   I have a table (named "table") with a large number of columns, but the related ones has the next structure:   id     date    import 1   201809     70 2   201809     88 1   20181...
  • Anonymous's avatar
    Anonymous
    7 years ago
    Hi, You could create a calculated table with this measure: Table = SUMMARIZECOLUMNS(Table1[id]; "201809";CALCULATE(SUM(Table1[import]);MONTH('Date'[Date])=08); "201810";CALCULATE(SUM(Table1[import]);MONTH('Date'[Date])=09); "201811";CALCULATE(SUM(Table1[import]);MONTH('Date'[Date])=10); "201812";CALCULATE(SUM(Table1[import]);MONTH('Date'[Date])=11) )
  • v-piga-msft's avatar
    7 years ago

    Hi Anonymous,

     

    By my tests, the formula from Chiara should be helpful.

     

    You also could create an index calculated column and a measure to achieve that.

     

    Index = 
    RANKX (
        FILTER (
            'Table2',
            EARLIER ( 'Table2'[id] ) = 'Table2'[id]
        ),
        [date],
        ,
        ASC
    )
    
    Measure =
    VAR a =
        CALCULATE (
            MAX ( Table2[import] ),
            FILTER (
                ALLEXCEPT ( 'Table2', Table2[id] ),
                'Table2'[Index]
                    = MAX ( 'Table2'[Index] ) - 1
            )
        )
    RETURN
        IF ( a = BLANK (), "Na", a )

     

    Best Regards,

    Cherry