2013-04-11 33 views
0

我的目标是在Visual Studio 2008中从我的SSRS表达式中获取以下结果。DueDate和InvoiceAmt是绑定字段(字段!duedate.Value和字段!valuehome_1 )。 “NotDueYet”和“0-30 Days”是具有引用绑定字段的表达式的别名。如何在SSRS中使用datediff

ClientInvoice >>> DUEDATE >>> InvoiceAmt >>>> NotDueYet >>>> 0-30天
4502767-00 >>>> 2013年4月8日>>>> $ 75.89 >>>>> >>>>>>>>>>>>>>> $ 75.89

4505151-00 >>>> 2013年4月11日>>> $ 137.26 >>>>>>> $ 137.26

总: >>>>>>>>>>>>>>>>>>>$ 213.15 >>>>>>>$ 137.26 >>>>>>$ 75.89

问题: 在别名列“NotDueYet”和“0-30 Days”中,基于我支持总计的iif/sum/datediff表达式,总数应该是仅显示在这些列中的详细数量(参见上文样品)。详细金额基于引用Duedate和InvoiceAmt绑定字段的表达式。相反,我得到以下结果;

ClientInvoice >>> DueDate >>> InvoiceAmt >>>> NotDueYet >>>> 0-30天
4502767-00 >>>> 4/8/2013 >>>> $ 75.89 >>>>> >>>>>>>>>>>>>>> $ 75.89

4505151-00 >>>> 2013年4月11日>>> $ 137.26 >>>>>>> $ 137.26

总: >>>>>>>>>>>>>>>>>>>$ 213.15 >>>>> >>$ 0.00包装 >>>>>>>>$ 213.15

这是我的每个领域的表达式;

InvoiceAmt(DETAIL):

=(fields!valuehome_1.Value) 

InvoiceAmt(TOTAL):

=Sum(fields!valuehome_1.Value) 

NotDueYet(DETAIL):

= iif(datediff("d",fields!duedate.Value,now())<= 0 
and (fields!valuehome_1.value>0),fields!valuehome_1.Value,"") 

NotDueYet(TOTAL):

= iif(datediff("d",fields!duedate.Value,now())<= 0 
and (fields!valuehome_1.value>0),SUM(fields!valuehome_1.Value),0) 

0-30天(详细信息):

= iif(datediff("d",fields!duedate.Value,now())>0 
and (datediff("d",fields!duedate.Value,now())<31 
and (fields!valuehome_1.value>0),fields!valuehome_1.Value,"") 

0-30天(TOTAL):

= iif(datediff("d",fields!duedate.Value,now())>0 
and (datediff("d",fields!duedate.Value,now())<31 
and (fields!valuehome_1.value>0),SUM(fields!valuehome_1.Value),0) 

我很欣赏解决这个神秘的任何援助。谢谢。

回答

0

嵌套是不完全正确:请尝试以下表达式:

对于NotDueYet(TOTAL):

=SUM(
    iif(datediff("d",fields!duedate.Value,now())<= 0 
     and (fields!valuehome_1.value>0), 
     fields!valuehome_1.Value, 
     0)) 

0-30天(TOTAL):

= SUM(
    iif(datediff("d",fields!duedate.Value,now())>0 
     and (datediff("d",fields!duedate.Value,now())<31 
     and (fields!valuehome_1.value>0), 
     fields!valuehome_1.Value, 
     0)) 

我想那应该得到你想要的。

+0

感谢您的回复。但是,我在每列的结果中获得#ERROR值。 ClientInvoice >>> DueDate >>> InvoiceAmt >>>> NotDueYet >>>> 0-30天 4502767-00 >>>> 4/8/2013 >>>> $ 75.89 >>>>>>>> >>>>>>>>>>>> $ 75.89 4505151-00 >>>> 4/11/2013 >>> $ 137.26 >>>>>>> $ 137.26 合计:>>>>>>> >>>>>>>>>>>> $ 213.15 >>>>>?>>#错误>>>>>>>>#错误 如果两列都有发票费用,我会得到正确的总额。 ClientInvoice >>> DUEDATE >>> InvoiceAmt >>>> NotDueYet >>>> 0-30天 4502767-00 >>>> 2013年4月8日>>>> $ 75.89 >>>>>>> $ 75.89 4505151-00 >>>> 4/11/2013 >>> $ 137.26 >>>>>>> $ 137.26 合计:>>>>>>>>>>>>>>>>>>> 213.15 >>>>>>>> $ 213.15 –