a SSRS 2008 problem:How to sum with a condition - ssrs-2008

I have a SSRS report in which there is two column Current_Product and TempAnnSaving.
Current_product has value current product and thier match. that means each current product have a match row or it may be more than one row.Each match row has a TempAnnSaving value in TempAnnSaving column.Now at the end of the report i have to show the total sum of TempannSaving,but there is a condition for sum--i have to sum only first match of each current product .
here is image http://www.imgplace.com/viewimg121/4385/96unled.png

aI guess that the "Current Product" is in the group, if so then do SUM provided by
=IIF (CountRows (Filed!namefield, "nameGroup") = 1, SUM (Field!namefield, "nameGroup"),Nothing)

Related

Crystal Report Count if all Details are not 0

I have a report with a list of orders and their product lines
the order lines have Qty ordered, Qty Delivered and Qty Backordered.
the Group header is the Sales Order number, the Details are all the product lines on that sales order.
I want to calculate in the Report footer the count of all Sales orders that have a backorder on them only.
I can do "if sum of backorder <> 0 then 1 else 0" in Group footer, but i cannot sum the result of this, i get "This field cannot be summarized" because you cannot sum a sum.
is there another way i can achieve this?
for example:(report sample)
this example should be 1 in the report footer because only one of the orders has a backorder.
thanks
Create a new formula with following content and name it #SalesWithBackOrder (The formula doesn't need to be placed anywhere on the report):
If {backorder} <> 0 Then
{SalesOrderNumber}
Else
0
or if {SalesOrderNumber} is text then:
If {backorder} <> 0 Then
{SalesOrderNumber}
Else
""
Then count the number of distinct values of the #SalesWithBackOrder formula.
You can do this by creating a new formula with following content (put it in your report-footer):
DistinctCount ({#SalesWithBackOrder})-1 // -1 because order-number "0" respectively "" is a distinct value too.

Tableau Column Difference - as a dimension

I am looking for difference of two columns in Tableau. I have the formula with me.
IF ATTR([Valuation Profile]) = "Base" THEN
LOOKUP(ZN(SUM([Value])), 1) > - ZN(LOOKUP(SUM([Value]),0)) END
But I get it as a separate column in the columns sections. How do I get that in the rows section? Basically how to get the difference as a dimension?
Please see attached images of what I want and what I have. Apparently, I cannot upload my excel sheet and tableau worksheet here. So I have upload just the screenshots.
What I have - vs - What I want
Tableau Workbook
First off, there is no way that you can generate additional rows for your data in Tableau!
In your case however you could use a workaround and do the following:
Create a calculated field for BASE and one for CSA. The formula should
be IF [Valuation Profile] = 'BASE' THEN [Value] END and IF
[Valuation Profile] = 'CSA' THEN [Value] END respectively
Afterwards you can drag Measure Names onto your rows shelf and
replace the SUM([Value]) with your two newly created calculated fields
that should give you all three measures in different rows in your table
Reference: https://community.tableau.com/message/627171#627171
Use LOD expression to calculate the individual values first.
Create calculated fields 'BASE', 'CSA' and 'CSA-BASE' as below.
BASE:
{FIXED [Book Name]: SUM( if [Valuation Profile] = 'BASE' then Value else 0 end ) }
CSA:
{FIXED [Book Name]: SUM( if [Valuation Profile] = 'CSA' then Value else 0 end ) }
CSA-BASE
[CSA]-[BASE]
Solution

crystal reports footer group sum

I want to sum the total amount of a field(it has to lines in sql so value should be 44+250=294) which belongs to a group but it peaks only the first line(44).
For example below is the formula that i have created.
if Sum({STOCK.QTYSTU_0},{#pickGrp3}) -Sum ({STOALL.QTYSTUACT_0}, {#pickGrp3}) = 0 then "EMPTY" else " "
Can you please advise?

Crystal Reports Formula Logic

I am using Crystal Reports 2008 and cannot figure out the proper expression for suppressing fields.
In this case, say I have a pill diary.
{PILL.TYPE_ANTI_INFLAMMATORY}
{PILL.TYPE_PAIN_REDUCTION}
{#INTEGER_TYPE1}
{#INTEGER_TYPE2}
The first two elements from the data tables PILL are columns of pill types. The first one is a column of type of anti-inflammatory pills, the second pain reduction. These columns each contain unique information.
In the second two elements, is a column of integers either negative or positive. These are formula columns (date difference between two dates.)
My expression:
{PILL.TYPE_ANTI_INFLAMMATORY} = "Advil" or
{PILL.TYPE_PAIN_REDUCTION} in ["Tylenol", "Acetometaphin"] and
{#INTEGER_TYPE1} > 1 or
{#INTEGER_TYPE2} > 1
What I am trying to do is display any row in which ANTI_INFLAMMATORY is equal to Advil or PAIN_REDUCTION is equal to Tylenol or Acetometaphin while also one of the columns of integer type is greater than 1.
(
{PILL.TYPE_ANTI_INFLAMMATORY}="Advil" or
{PILL.TYPE_PAIN_REDUCTION} IN ["Tylenol","Acetometaphin"]
) and
(
{#INTEGER_TYPE1} > 1 or
{#INTEGER_TYPE2} > 1
)
IF ({PILL.TYPE_ANTI_INFLAMMATORY}="Advil" or {PILL.TYPE_PAIN_REDUCTION} IN ["Tylenol","Acetometaphin"])
AND
({#INTEGER_TYPE1} > 1 or {#INTEGER_TYPE2} > 1) THEN
FALSE ELSE TRUE

How can I order a group, based on a summary field of a subgroup

I have a report which has essentially
Order
OrderDetail 1
OrderDetail ..
OrderDetail n
These details can have parts and/or labour costs associated with them.
Currently, I group based on OrderId and then have the OrderDetail information in the details section of the report. This works perfectly.
However, now I need to group the Orders based on two criteria OrderType and LabourCost of the entire Order. I have put together a quick formula to determine order.
if(Sum({order.Labour}, {order.OrderId})> 0) then
if({order.type} = "type1") then 1 else 2
else
if({order.type} = "type1") then 3 else 4
Basically, if it should be sorted based on labour then on type. (the Sum({order.Labour}, {order.OrderId}) sums the labour grouping based on the orderid)
However when I go to the Group Expert and add the group by field to my formula and then preview my report it spins (I cancelled the preview after a minute). If I remove the Sum portion of the formula then it takes less than a second.
Is there a way to order this report?
How I would approach it:
First, create a sql-expresssion field that calculates the labor total for each order:
// {%TOTAL_LABOR}
(
SELECT Sum(Labour)
FROM OrderDetail
WHERE OrderId=Order.OrderId
)
Next, create a formula field:
// {#OrderGroup}
if({%TOTAL_LABOR}> 0) then
if({order.type} = "type1") then 1 else 2
else
if({order.type} = "type1") then 3 else 4
Finally, create a new group, based on the formula field, ensuring that it groups before the order group. You can suppress the group's header and footer if desired.