简体   繁体   English

在使用表达式 SSRS 使用两个数据集进行计算时需要帮助

[英]Need help in calculation using two Datasets using Expression SSRS

I am creating an SSRS report where我正在创建一个 SSRS 报告,其中

In Dataset15, I have value Jan - 100 & Feb - 110在 Dataset15 中,我的值为 Jan - 100 & Feb - 110

in Dataset16, I have value Jan - 80 & Feb - 100在 Dataset16 中,我有价值 Jan - 80 & Feb - 100

Now I want to calculate same thing in a line chart using expression - Jan - 80/100 which should be 80% & Feb - 100/110 - 91%现在我想使用表达式 - Jan - 80/100在折线图中计算相同的东西,它应该是 80% & Feb - 100/110 - 91%

When I am trying to find out individual monthly number 100, 110 I am getting 210 which is the summation of Both - Sum(Fields!Total.Value, "DataSet15") .当我试图找出每个月的数字 100, 110 时,我得到 210,这是两者的总和 - Sum(Fields!Total.Value, "DataSet15")

Kindly help me out how can I get individual Numbers.请帮助我如何获得个人号码。

You would need to restrict your dataset to the desired month and then sum the results.您需要将数据集限制为所需的月份,然后对结果求和。

LookupSet is used to retrieve data from another dataset based on criteria. LookupSet用于根据条件从另一个数据集中检索数据。

A VBA function, SumLookup is needed to add the results from the LookUp.需要一个 VBA 函数 SumLookup 来添加 LookUp 的结果。 This VB would go into the CODE section of the report (this can be seen under 'Report Properties').这个 VB 将进入报告的 CODE 部分(这可以在“报告属性”下看到)。

Function SumLookup(ByVal items As Object()) As Decimal

If items Is Nothing Then Return Nothing

Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()

suma = 0
ct = 0

For Each item As Object In items

  suma += Convert.ToDecimal(item)
  ct += 1

Next

If (ct = 0) Then return 0 else return suma 

End Function 

You would then use the function in your expression like:然后,您将在表达式中使用该函数,例如:

=Code.SumLookup(LookupSet(Fields!MONTH.Value, Fields!MONTH.Value, Fields!Total.Value,"Dataset16"))

If your field is a date, then you'd need to convert both to a MMyyyy field with FORMAT:如果您的字段是日期,那么您需要使用 FORMAT 将两者都转换为 MMyyyy 字段:

FORMAT(Fields!MONTH.Value, "MMyyyy")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM