Skip to Content
author's profile photo Former Member
Former Member

Using Previous with Variable/Formula

I have one formula (formula1) that does some calculations and works well. I need to implement a second formula, which would be based on the value in formula1. I want formula2 to look something like this:

IIf {fieldA.Value} = Previous{fieldA.Value}, IIf(formula1.Value <> Previous(formula1.value), formula1.Value, ""),"")

Each time I try that I get an error highlighting Previous(formula1.Value), saying "This field has no previous or next value".

I've tried to default the formula1 value if its the first record, I've moved the formulas around to different sections, but I can't seem to get rid of that error.

Is there a way to get around this?

Any help is appreciated!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2013 at 05:52 PM

    the error is likely being thrown on the first record which, by design, has no previous record

    try adding another line of code at the begining of your formula . . .

    if onfirstrecord then "" else . . . . .

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 06, 2013 at 05:38 PM

    hi Bernadette,

    this error with previous or next usually occurs when you're referencing a Summary (Sum, Maximum, etc.) or a formula that contains a Summary.

    i would suggest that you look into bringing the summary in with a SQL Expression if possible and if you can't, use a Command object for your data instead of tables and have the summary brought into the Command via a sub-query.

    -jamie

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Jamie,

      Thanks for the reply. Formula1 is really just a flag to determine the status of a deal based on the most current date, so I don't think its a summary issue.

      The data is coming from a universe, which leaves me at a loss of how to bring it in that way. I was hoping for a way to do it in a formula.

      Thanks!

  • author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2013 at 06:49 PM

    I think I found the problem. I had created formula1 as a formula, and then tried it as a variable. The testing I did from the suggestions here were on the variable. When I went back to the straight formula, and had onfirstrecord, it worked.

    My mistake. 😳

    Thanks for all the help!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.