nathanpz
asked on
Dataset Column Expression With Conditional Outputs
Hi,
How do you set a column expression to assign a large number of string values that are determined by an existing column value?
I have numbers ranging from 0 to 30 say in my existing [New Score] column. I wan't my column expression on my [Level] column to show the following:
New Score Level
1-3 A
3-6 B
6-9 C
etc etc
24-27 I
27-30 J
I have used an IIF statement before to handle just two classifications "High" and "Low" levels, but cannot get VB.NET to extend to the multiple-argument. The line below works fine for two [Level] values only.
ds.Tables(2).Columns("Leve l").Expres sion = "IIF([New Score] < 15, 'Low', 'High')"
How do I get more than a true/false conditional expression?
Thanks,
Nathan.
How do you set a column expression to assign a large number of string values that are determined by an existing column value?
I have numbers ranging from 0 to 30 say in my existing [New Score] column. I wan't my column expression on my [Level] column to show the following:
New Score Level
1-3 A
3-6 B
6-9 C
etc etc
24-27 I
27-30 J
I have used an IIF statement before to handle just two classifications "High" and "Low" levels, but cannot get VB.NET to extend to the multiple-argument. The line below works fine for two [Level] values only.
ds.Tables(2).Columns("Leve
How do I get more than a true/false conditional expression?
Thanks,
Nathan.
or you could use the switch function, something like
dim s as integer = 9
MsgBox(Microsoft.VisualBas ic.Switch( s < 4, "A", s < 6, "B", s < 10, "C"))
dim s as integer = 9
MsgBox(Microsoft.VisualBas
ASKER
Hi RonaldBiemans,
I don't think the IIF statement can be nested in VB.NET. It says I am using too many arguments if I have more than IIF(argument,val_true,val_ false).
Also, the Switch function wont allow me to use the [New Score] column values. I can't easily code the switch function to alter each [Level] column entry because the [Level] column is readonly and part of a dataset so it needs to use the Dataset.DataColumn.Express ion command. Do you know how this could be coded?
Any ideas how to alter on of the above functions to work with my dataset column?
Thanks,
Nathan.
I don't think the IIF statement can be nested in VB.NET. It says I am using too many arguments if I have more than IIF(argument,val_true,val_
Also, the Switch function wont allow me to use the [New Score] column values. I can't easily code the switch function to alter each [Level] column entry because the [Level] column is readonly and part of a dataset so it needs to use the Dataset.DataColumn.Express
Any ideas how to alter on of the above functions to work with my dataset column?
Thanks,
Nathan.
I'll have a look, but I'm pretty sure the iif can be nested.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Could you post your expression maybe you made a small type error.
ASKER
Thanks for persevering RonaldBiemans,
I wasn't being careful enough with the number of arguments in the nested IIF statement.
The points are yours.
Thanks again.
Nathan.
I wasn't being careful enough with the number of arguments in the nested IIF statement.
The points are yours.
Thanks again.
Nathan.
Dim s As Integer = 12
ds.Tables(2).Columns("Leve