Getting value for marge calculating 

Getting value for marge calculating 

  
Hi,

Having a question about getting the right value from a table, where the variable/parameter is the columnname.
The user selects a marge value from a special list ( this is a combobox ) for an article.

The value of this selected combobox must be equal to the column name in PriceMarge table, so the right storeprice can be calculated
getting the value according the columnname. (send an attachment)

For example if the combobox value = Equal to 24
and the price = 84.95

The value i want to get = 35.40

Any idea, how to solve this technical point?


Was waiting for some feedback message... but After Putting enough Time into this technical point, I build a Switch which checks what column must be Taken
for getting the right Value from the Different Column...

It seems as follows =)

Working Perfect !
This Solved my Problem...

You can also do this using an advanced query .... you would have to "build" the column name previously and pass it in (i.e. "{SALES_VIEW}.[MARGIN24]").  The parameter  you pass in you will want to set as expand inline.  This avoid having a complicated switch statement.

Something like this:
Hello Yusuf,

You really should follow the tip given by Rebecca for many reasons..
You'l have a very clean and readable code, easier to maintain, better performance (since you'll query the DB directly - no additional logic) and you'l save a lot of Software Units.
Don't forget to change the parameter highlighted by Rebecca (Expand inline = True), because otherwise it won't work.
This describes whether the parameter should be textually expanded into the SQL or used as a common parameter.
Just a note - When using expand inline parameters, you should use the EncodeSql function to prevent SQL injection in the database.

Kind Regards,
Gonçalo Martins