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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JL0101
Helper II
Helper II

Finding a previous value based on another column

I have the following measure below, however it just returns blank when I insert the measure into a prexisting table, any idea why?
 
ModelA-Weight Difference1
a 
b 
c 
d 
e 
 
 
A-Weight Difference1 =
VAR PreviousRev =
    CALCULATE ( MAX ( 'Full_Rebar'[C-Revision Number] )-1)
RETURN
    CALCULATE ( MAX ( 'Full_Rebar'[weight_calculated ), 'Full_Rebar'[C-Revision Number] = PreviousRev )
 
would it have anything todo with filter context? as there is another measure in the table too.
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

@PhilipTreacy Thanks for your contribution on this thread.

Hi @JL0101 ,

You can update the formula of measure [A-Weight Difference] as below and check if it can return the expected result.

A-Weight Difference =
VAR _Revnum =
    MAX ( 'Full_Rebar'[C-Revision Number] )
VAR PreviousRev =
    CALCULATE (
        MAX ( 'Full_Rebar'[C-Revision Number] ),
        FILTER (
            ALLSELECTED ( 'Full_Rebar' ),
            'Full_Rebar'[C-Revision Number] < _Revnum
        )
    )
VAR _preweight =
    CALCULATE (
        SUM ( 'Full_Rebar'[weight_calculated] ),
        FILTER (
            ALLSELECTED ( 'Full_Rebar' ),
            'Full_Rebar'[C-Revision Number] = PreviousRev
        )
    )
RETURN
    SUM ( 'Full_Rebar'[weight_calculated] ) - _preweight

If the above ones can't help you figure out, please provide some raw data in your table 'Full_Rebar' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

@PhilipTreacy Thanks for your contribution on this thread.

Hi @JL0101 ,

You can update the formula of measure [A-Weight Difference] as below and check if it can return the expected result.

A-Weight Difference =
VAR _Revnum =
    MAX ( 'Full_Rebar'[C-Revision Number] )
VAR PreviousRev =
    CALCULATE (
        MAX ( 'Full_Rebar'[C-Revision Number] ),
        FILTER (
            ALLSELECTED ( 'Full_Rebar' ),
            'Full_Rebar'[C-Revision Number] < _Revnum
        )
    )
VAR _preweight =
    CALCULATE (
        SUM ( 'Full_Rebar'[weight_calculated] ),
        FILTER (
            ALLSELECTED ( 'Full_Rebar' ),
            'Full_Rebar'[C-Revision Number] = PreviousRev
        )
    )
RETURN
    SUM ( 'Full_Rebar'[weight_calculated] ) - _preweight

If the above ones can't help you figure out, please provide some raw data in your table 'Full_Rebar' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
PhilipTreacy
Super User
Super User

@JL0101 

 

Please provide data and excpected result.  I can't tell from what you have provided what data you are using or what you expect is the correct result.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.