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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
LoganFFS
Regular Visitor

Calculated Column

Hi there, I am trying to make a calculated column that simply pulls a value from another column if the preceeding row has a certain value. in a different column. I have an index column named "Row #" with row number as shown below that the EARLIER function can be based on. I dont want it sorted by anything othger than the previous action being a cell. I have provided a screenshot of what I hope to accomplish. Any help is appreciated, thanks!

Screenshot 2025-06-01 at 1.26.49 PM.png

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I tried to use OFFSET DAX function in the calculated column formula.

 

Jihwan_Kim_0-1748833533816.png

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

value(price) calculated column = 
VAR _nextrow =
    MAXX (
        OFFSET ( 1, SUMMARIZE ( data, data[row#] ), ORDERBY ( data[row#], ASC ) ),
        data[row#]
    )
VAR _nextaction =
    MAXX ( FILTER ( data, data[row#] = _nextrow ), data[action] )
VAR _condition = _nextaction = "sell"
    && data[action] = "buy"
RETURN
    IF ( _condition, data[price] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

5 REPLIES 5
FBergamaschi
Post Prodigy
Post Prodigy

Can you explain a little deeper what you want to accomplish and in which situation?

v-achippa
Community Support
Community Support

Hi @LoganFFS,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @Jihwan_Kim for the prompt response.

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user resolved your issue? or let us know if you need any further assistance.
If any response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @LoganFFS,

 

We wanted to kindly follow up to check if the solution provided by the user resolved your issue.

If any response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @LoganFFS,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user resolved your issue.
If any response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I tried to use OFFSET DAX function in the calculated column formula.

 

Jihwan_Kim_0-1748833533816.png

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

value(price) calculated column = 
VAR _nextrow =
    MAXX (
        OFFSET ( 1, SUMMARIZE ( data, data[row#] ), ORDERBY ( data[row#], ASC ) ),
        data[row#]
    )
VAR _nextaction =
    MAXX ( FILTER ( data, data[row#] = _nextrow ), data[action] )
VAR _condition = _nextaction = "sell"
    && data[action] = "buy"
RETURN
    IF ( _condition, data[price] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.