mardi 6 septembre 2016

SSRS how to use If and format statement together for negative values

I am trying to display seconds as minutes. Sometimes the value I get is negative. This causes problems. I wanted to check if the value is negative so that I can assign a default value. But I can not get If and Format statement work together.

This is what I have done to display the values without converting into minutes:

=Fields!RateLossSeconds.Value

enter image description here

This is what I have done to convert the seconds into minutes:

=Format(DateAdd("s", Fields!RateLossSeconds.Value, "00:00"), "mm:ss")

enter image description here

This is the code I used to add a condition:

=IIF(Fields!RateLossSeconds.Value < 0, 0, Format(DateAdd("s", Fields!RateLossSeconds.Value, "00:00"), "mm:ss"))

As you can see the if statement does not work as desired.

enter image description here

Aucun commentaire:

Enregistrer un commentaire