Sum of expressions with if clause


i have column positive , negative values.

positive values means number of goods sold, determine profit, multiply quantity selling price.

negative values mean number of goods not sold , worth nothing anymore, determine cost, multiply quantity costprice.

the prices come in different columns

e.g.quantity   |   price   |   name   |   profit     |    cost

          5               12            a            5*12             0

          -3              5             b             0              -3*5

          ...              ...            ...            ...                 ...

 so profit , cost calulated expressions, can't in sql query because of if clause

but need have total of of profits and costs.

any idea how total in report builder?         


hi piri10,

after testing issue in environment, can refer following expression achieve requirement:
=sum(iif(fields!verschil.value>0,fields!verschil.value*fields!verkoops_eenhprijs.value,0),"dataset_name")+sum(iif(fields!verschil.value<0,fields!verschil.value*fields!enhprijs.value,0),"dataset_name")

if there other questions, please feel free ask.

regards,
katherine xiong


katherine xiong
technet community support



SQL Server  >  SQL Server Reporting Services, Power View



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........