Forum Discussion

abdalla's avatar
abdalla
Helper I
4 years ago
Solved

Latest value

Hello, I want to make a column that holds the last shut in pressure-psia according to the latest active month date. I looked at other posts but cant seem to figure out the right code. Please...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi abdalla ,

    Please try below dax formula to add a new column:

    Column =
    VAR cur_active_month = 'Table'[Active Month]
    VAR cur_wellname = 'Table'[well name]
    VAR cur_well = 'Table'[Well]
    VAR cur_string = 'Table'[String]
    VAR cur_reservoir = 'Table'[Reservoir]
    VAR last_month =
        CALCULATE (
            MAX ( 'Table'[Active Month] ),
            FILTER (
                'Table',
                'Table'[Well] = cur_well
                    && 'Table'[String] = cur_string
                    && 'Table'[Reservoir] = cur_reservoir
                    && 'Table'[well name] = cur_wellname
            )
        )
    RETURN
        CALCULATE (
            MAX ( 'Table'[Shut in Pressure-psia] ),
            FILTER (
                'Table',
                'Table'[Active Month] = last_month
                    && 'Table'[Well] = cur_well
                    && 'Table'[String] = cur_string
                    && 'Table'[Reservoir] = cur_reservoir
                    && 'Table'[well name] = cur_wellname
            )
        )
    

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.