Need more, need help now?
- - - - - - - - - - - - - - - - - - pay-as-you-go support - no contract - tenth of an hour billing - expert help - fast service - no call queues
Need integration?
- - - - - - - - - - - - - - - - - - with your shipping system - website - invoicing system - crm - cms - manufacturing - order import - back to back orders..
Need a report?
- - - - - - - - - - - - - - - - - - Excel reporting that pulls data from Sage - custom layouts - layouts that change adapt to your brands and/or for drop shipping.
Want web hosting?
- - - - - - - - - - - - - - - - - - Your own domain name - email - a shop - wordpress - woo commerce - ticket systems - help desks - forums - portals

If statement

Report design issues and solutions.
Post Reply
davemunro
User
User
Posts: 1
Joined: 24 Jun 2014, 10:05
Sage Version: v2014 20 UK/Europe/Africa

If statement

Post by davemunro » 24 Jun 2014, 10:22

Good morning,
New to the forums so hello to all! We use Sage Accounts Professional 2014
I'm trying (in vain so far) to create an expression:
I have two separate expressions which I want to combine into a single if statement expression
expr1 StringToInteger(SOP_ITEM.COMMENT_2) * StringToInteger(SOP_ITEM.EXT_ORDER_REF) * 6.3 / 1000000
expr2 STOCK.UNIT_WEIGHT * 6.3

If expr2 is less than or equal to 0 then use expr1, if the value is less than 0.26 then set the result to 0.26

The context of the expressions is to calculate square meter rates of a particular item, setting the minimum rate to 0.26 if the result is less than that..

I hope I've explained that well enough.

Thanks in advance.

Dave

User avatar
brucedenney
Site Admin
Site Admin
Posts: 4629
Joined: 28 Feb 2006, 09:56
Sage Version: v28 UK/Europe/Africa

Re: If statement

Post by brucedenney » 24 Jun 2014, 11:22

The if function is confusing.

Because there are 2 of them, one the "if" is only used in properties.

In expressions you need to use the ? : version

Condition ? Instruction 1 : Instruction 2

In your case you need to nest conditions

Condition 1 ? Instruction 1 : Condition 2 ? Instruction 2 : Instruction 3
For just about anything Sage :- Discount subscriptions, pay-as-you-go support, application integration, reports, layouts, linked excel spreadsheets, analysis or any other help making life with sage easier/less time consuming Contact me.

Geordie
User
User
Posts: 2
Joined: 25 Jun 2014, 22:11
Sage Version: v2014 20 UK/Europe/Africa

Re: If statement

Post by Geordie » 25 Jun 2014, 22:32

Dave

Having looked at what you have asked, you could combine the 2 expressions into one such as:

STOCK.UNIT_WEIGHT * 6.3 <= 0 ? (StringToInteger(SOP_ITEM.COMMENT_2) * StringToInteger(SOP_ITEM.EXT_ORDER_REF) * 6.3 / 1000000 < 0.26 ? 0.26 : StringToInteger(SOP_ITEM.COMMENT_2) * StringToInteger(SOP_ITEM.EXT_ORDER_REF) * 6.3 / 1000000) : 0.26

However I am not at my Sage Computer to test this out in practice.
The easiest solution is to do a 3rd expression which references EXPR1 and EXPR2, such as:

EXPR2 <= 0 ? (EXPR1 < 0.26 ? 0.26 : EXPR1) : 0.26

This is saying that if Expression 2 is equal or less than 0 then to look at Expression1, there is another if in brackets, looking at the result of expression 1, if this is less than 0.26, then return 0.26, otherwise give the value returned for Expression 1 (which will be 0.26 or greater) otherwise just return 0.26.

However, the flaw in this is that Expression 2 could return a value for example 0.1 in which case the result of the 3rd expression will be 0.1.

Its difficult to give an accurate expression without looking at a sample of what EXPR1 and EXPR2 return, however, I expect, EXPR2 never returns anything between 0 and 0.26 ?

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests