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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hnsbhat
Helper I
Helper I

How to refer to the results of the same measure

Hello,  I want to create a measure which refers to the result of the same measure for the previous rows. I want a Criteria Measure in the below table for which criteria is : IF ((<low> less then low -2) AND <close> less than <close> of previous date which has criteria as 'Yes') THEN "Yes"

Below is the sample data and I have manually put the Criteria to illustrate what I want. Is there any way we can achieve this in power pivot? Thanks in advance for any help here. 

 

<date><ticker><open><high><low><close><rank>Low -2 MeasureCriteria Measure
9/12/2017xyz184.95193.30184.95192.357  
9/13/2017xyz192.80194.40188.60189.558  
9/14/2017xyz190.50198.00190.10196.059184.95 
9/15/2017xyz195.95196.65189.05190.1010188.60 
9/18/2017xyz191.75192.80189.10189.7511190.10Yes
9/19/2017xyz191.70192.95187.50189.9012189.05 
9/20/2017xyz190.40190.90185.00185.5013189.10Yes
9/21/2017xyz185.00185.75180.60182.9514187.50Yes
9/22/2017xyz180.65181.45175.15175.8515185.00Yes
9/25/2017xyz175.50175.70164.50167.5016180.60Yes
9/26/2017xyz168.05174.45167.25171.6017175.15 
9/27/2017xyz173.90174.10164.45165.6518164.50Yes
1 ACCEPTED SOLUTION

Hi @hnsbhat,

If you want to get "Yes" for rows where <close> less than <close> of previous date which has criteria as 'Yes'. You just need to create another calculated column using the formula and get expected result.

=
IF (
    [<low>] <= [Low -2 Measure]
        && [<close>] <= [<close> of previous date]
        && LOOKUPVALUE ( [Criteria Measure], [<rank>], [<rank>] - 1 )
            = "Yes",
    "Yes",
    BLANK ()
)

1.PNG

Best Regards,
Angelia

View solution in original post

3 REPLIES 3
v-huizhn-msft
Employee
Employee

Hi @hnsbhat,

Of course, you can achieve it in Power Pivot. Please follow the steps below.

1. Add your sample table into pivot model.

2. Create a calculated column to get <close> less than <close> using the formula.

=LOOKUPVALUE([<close>],[<rank>],[<rank>]-1)


3. Create another calculated column to get Criteria Measure using the formula.

=IF([<low>]<=[Low -2 Measure]&&[<close>]<=[<close> of previous date],"Yes",BLANK())


Please review the expected result as the screenshot shown.

right resultright result
Best Regards,
Angelia

Hi v-huizhn-msft,  Thanks for your reply, however it looks like the solution you have provided checks only if the close is less than previous close. But what I need is - <close> less than <close> of previous date which has criteria as 'Yes'.  That means even if a close is less than previous close but more than the previous date which has Criteria "Yes", then I should not get "Yes" for current date. Only when the close is less than the close of previous date with criteria 'Yes' I need to get 'Yes' in current row.

 

One more thing to consider is in future I can add few more conditions to the criteria, but the last condition should be to check if the current close is less then close of previous date which fullfilled the criteria. Hope this is clear. Thanks!

Hi @hnsbhat,

If you want to get "Yes" for rows where <close> less than <close> of previous date which has criteria as 'Yes'. You just need to create another calculated column using the formula and get expected result.

=
IF (
    [<low>] <= [Low -2 Measure]
        && [<close>] <= [<close> of previous date]
        && LOOKUPVALUE ( [Criteria Measure], [<rank>], [<rank>] - 1 )
            = "Yes",
    "Yes",
    BLANK ()
)

1.PNG

Best Regards,
Angelia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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