Link to home
Create AccountLog in
Avatar of aneilg
aneilgFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SSRS Expression

i have the following expression.
=Switch(
      fields!PercentFlag.Value ="H", format(fields!Time.Value, "HH:mm"),
      ((Fields!PercentFlag.Value ="Y")AND (Fields!Value.Value >0)), Format(Sum(Fields!Value.Value * 100), "0.0"),
      True, Replace(cStr(Sum(Fields!Value.Value)),".0","")
)

produces 026369797987998

but when i take out

AND (Fields!Value.Value >0))

so i am left with

=Switch(
      fields!PercentFlag.Value ="H", format(fields!Time.Value, "HH:mm"),
      ((Fields!PercentFlag.Value ="Y")), Format(Sum(Fields!Value.Value * 100), "0.0"),
      True, Replace(cStr(Sum(Fields!Value.Value)),".0","")
)

i get 2.7. but if the value = 0 i get 0.0.

why does my first expression does not work.
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

switch is not always the best way in expressions.
can you explain alittle on what you are wanting to do with your data
Avatar of aneilg

ASKER

basically if my value is greater than 0, then format the date. but when i add 'AND (Fields!Value.Value >0))' the formatting does not work.
This may be a little off on the syntax but I think you will be able to adjust it.
Use a IIF nest IN a IIF.

 =IIF(fields!PercentFlag.Value ="H", format(fields!Time.Value, "HH:mm"),
  IIF (Fields!PercentFlag.Value ="Y" AND (Fields!Value.Value > 0), Format(Sum(Fields!Value.Value * 100), "0.0"), Replace(CStr(Sum(Fields!Value.Value)), ".0", False, True))
ASKER CERTIFIED SOLUTION
Avatar of aneilg
aneilg
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of aneilg

ASKER

question can be closed. no answer given. but the solution has been resloved.