Want to filter on the basis of a global variable

sadozaiwsadozaiw Member Posts: 19
Dear All!
I have made a report "Stock Evaluation" on Item table. In our database, the Unit Price is comming from another table called "Sales Price".
So i made a variable in the report and am taking unit price in it from Sales price table.
The problem is how can i allow users to filter according to unit price like unit price > 2000 or < 3000 etc.
Please help
Thanks.
Do to others as you wish others to do to you.

Comments

  • WaldoWaldo Member Posts: 3,412
    I'm not sure if I understand exactly, but it seems you're just asking for how to filter? Just search the help on "Entering Criteria in Filters", and there's what you need.

    In your case, you can filter like '>2000&<3000' to get every price between 2000 and 3000. '2000..3000' should work as well.

    Is this what you want?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • FramusFramus Member Posts: 13
    I'm not sure too if I understand, but if you want to allow user filter on unit price, take new field on Request form, where the user can set the filter (for ex. >2000&<3000) and then use the filter
    UnitPrice.SETFILTER("unit price",'%1',ReqFormValueFilter);
  • sadozaiwsadozaiw Member Posts: 19
    Let me clarify what is the problem. I have made a report based on dataitem "ITEM" table. Now unit price is in another table called Sales Price.
    so i made a globalariable in the report and called "UnitPrice" and then write code in my report to populate this variable. Until here, i have no problem.
    The problem is that now user wants to filter the report on the basis of Unit Price, which is a variable, so how can they filter on the basis of a variable?
    The other problem is that the datatype of Unit Price in sales price table is decimal and if i make a new text box in request form, and keep it's datatype to decimal, it will not take any operator as > or <less than
    please help.
    Do to others as you wish others to do to you.
  • FramusFramus Member Posts: 13
    Use two box on reqest form with two wariable (unitpricefrom, unitpriceto - decimal) and then filter records in OnPreDataItem
    SETRANGE("Unit price",unitpricefrom,unitpriceto);
    or use one text box with variable of type CODE (fe. MyFilter) and then filter
    SETFILTER("Unit price",MyFilter);
  • sadozaiwsadozaiw Member Posts: 19
    Hi Framus!
    Thanks for your reply, i tried it but it is giving me compilation error
    Type conversion not allowed
    Decimal := Code

    The column in the sales price table is of datatype decimal, and MyFilter is of type Code,
    I tried to make the MyFilter decimal aswell but it will not take any operator.
    Pls help.....
    Do to others as you wish others to do to you.
  • FramusFramus Member Posts: 13
    Yes, you must filter
    SETFILTER("Unit Price",MyFilter); (not "Unit Price",'%1',Myfilter)
    I repaired it.
  • sadozaiwsadozaiw Member Posts: 19
    Thanks a lot Farmus! this did the trick. :lol:
    Do to others as you wish others to do to you.
Sign In or Register to comment.