Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
abdalla
Helper I
Helper I

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.

abdalla_0-1658733306767.png

Please tell me what i can do for such

Thank you.

 

 

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

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
        )
    )

vbinbinyumsft_0-1658908402520.png

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.

View solution in original post

6 REPLIES 6
v-binbinyu-msft
Community Support
Community Support

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
        )
    )

vbinbinyumsft_0-1658908402520.png

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.

Works like a charm Thank you sir.

abdalla
Helper I
Helper I

hello amit,

Please find the attached pbix file and my expected outcome is the data plot column but my problem here is that this column includes data for all and all i want is just the latest shut in pressure for each well you can see that there are wells that are repeated and i only need the latest value of the shut in pressure of that well. https://app.powerbi.com/links/mtLTLIX4RX?ctid=8644cd89-6ec4-47c4-9147-055c60b5ada2&pbi_source=linkSh...

@abdalla , No Access to the file

how can i share the file 

when i copy it to here it says that pbix is not supported!

 

amitchandak
Super User
Super User

@abdalla , Refer if my blog can help

 

https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors