Function equivalent to SUM() for multiplication in SQL Reporting

二次信任 提交于 2019-12-24 14:16:33

问题


I'm looking for a function or solution to the following:

For the chart in SQL Reporting i need to multiply values from a Column A. For summation i would use =SUM(COLUMN_A) for the chart. But what can i use for multiplication - i was not able to find a solution so far?

Currently i am calculating the value of the stacked column as following:

=ROUND(SUM(Fields!Value_Is.Value)/SUM(Fields!StartValue.Value),3)

Instead of SUM i need something to multiply the values. Something like that:

=ROUND(MULTIPLY(Fields!Value_Is.Value)/MULTIPLY(Fields!StartValue.Value),3)

EDIT #1

Okay tried to get this thing running. The expression for the chart looks like this:

=Exp(Sum(Log(IIf(Fields!Menge_Ist.Value = 0, 10^-306, Fields!Menge_Ist.Value)))) / Exp(Sum(Log(IIf(Fields!Startmenge.Value = 0, 10^-306, Fields!Startmenge.Value))))

If i calculate my 'needs' manually i have to get the following result:

In my SQL Report i get the following result:

To make it easier, these are the raw values:

and you have the possibility to group the chart by CW, CQ or CY (The values from the first pictures are aggregated Sum values from the raw values by FertStufe)

EDIT #2

Tried your expression, which results in this:

Just to make it clear:

The values in the column

=Value_IS / Start_Value

in the first picture are multiplied against each other

0,9947 x 1,0000 x 0,59401 = 0,58573

Diffusion Calenderweek 44 Sums

Startvalue: 1900,00 Value Is: 1890,00 == yield:0,99474

Waffer unbestrahlt Calenderweek 44 Sums

Startvalue: 620,00 Value Is: 620,00 == yield 1,0000

Pellet Calenderweek 44 Sums

Startvalue: 271,00 Value Is: 160,00 == yield 0,59041


yield Diffusion x yield Wafer x yield Pellet = needed Value in chart = 0,58730

EDIT #3 The raw values look like this:

The chart ist grouped - like in the image - on these fields CY (Calendar year), CM (Calendar month), CW (Calendar week)

You can download the data as xls here:

https://www.dropbox.com/s/g0yrzo3330adgem/2013-01-17_data.xls

The expression i use (copy / past from the edit window)

=Exp(Sum(Log(Fields!Menge_Ist.Value / Fields!Startmenge.Value)))

I've exported the whole report result to excel, you can get it here: https://www.dropbox.com/s/uogdh9ac2onuqh6/2013-01-17_report.xls


回答1:


it's actually a workaround. But I am pretty sure is the only solution for this infamous problem :D

This is how I did:

Exp(∑(Log(X))), so what you should do is:

Exp(Sum(Log(Fields!YourField.Value)))

Who said math was worth nothing? =D

EDIT:

Corrected the formula.

By the way, it's tested.

Addressing Ian's concern:

Exp(Sum(Log(IIf(Fields!YourField.Value = 0, 10^-306, Fields!YourField.Value))))

The idea is change 0 with a very small number. Just an idea.

EDIT:

Based on your updated question this is what you should do:

Exp(Sum(Log(Fields!Value_IS.Value / Fields!Start_Value.Value)))

I just tested the above code and got the result you hoped for.



来源:https://stackoverflow.com/questions/14374470/function-equivalent-to-sum-for-multiplication-in-sql-reporting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!