I am trying to understand expression in QV for the past few days and am unable to follow what it is trying to do especially the aggregate part with a nodistinct sum.
I've tried to understand how aggregate works and how nodistinct with sum but am not able to connect with the rest of the expression.
sum([INFLUENCE ON SALE]
* aggr(NODISTINCT SUM({<PART_NUMBER, [INFLUENCE ON SALE],[Campaign
Name],ROOTCAUSE=>}[TOTAL OCCATIONS 12]),KEY,YEAR)
/aggr(NODISTINCT SUM({<PART_NUMBER, [INFLUENCE ON SALE],[Campaign
Name],ROOTCAUSE=>}[TOTAL OCCATIONS 12]),YEAR))
WHAT is this expression trying to do with the aggregate and nodistinct part. can this be simplified and explained with a simple example?
you have to show the chart (table) in order to understand the use of nodistinct in this specific calculation. nodistinct "spreads" the results across dimensions even though the dimension is not in the aggr function...
Related
I have a report with two datasets to summarise the number and value of incomplete orders by status. I have a "Back Order" column, which is using the 'Lookup' function to refer to a second database, based on a whether the Fields!IsBackorder.Value returns true. This works at line level, but I've run into issues at the aggregate level.
For the total count of orders, this forumula works:
=SUM(IIF(LOOKUP(Fields!SalesOrderID.Value, Fields!SalesOrderID.Value, Fields!IsBackorder.Value, "DstBackorders") = "TRUE",1,0))
However, for the total value of orders ("Fields!NetValue.Value"), this returns '#Error'
=SUM(IIF(LOOKUP(Fields!SalesOrderID.Value, Fields!SalesOrderID.Value, Fields!IsBackorder.Value, "DstBackorders") = "TRUE",Fields!NetValue.Value,0))
I've tried custom aggregate functions but I haven't found any that work. I'm not sure how I'm getting this error.
Any suggestions would be really helpful.
Thanks,
Report Screenshot
The syntax looks perfectly fine , also the lookup looks good , can you please check on the below things in your DataSet:
Is Fields!NetValue.Value in scope of the current DataSet.
Are we using the correct data type for Fields!NetValue.Value(Something which is aggregatable , like int , decimal etc.)
I am writing a report that needs to display a different datediff calculation based on a specific Value from a column. If the order is "Active" start time to Now or if the order is ceased start time to stop time.
The individual DateDiff expressions work but when I try to combine them in one expression using either switch or IIF I get errors.
Any suggestions would be great.
=IIF(Fields!OrderStatus.Value="Active", DateDiff("d",Fields!OrderStartTime.Value, "Now"()),
IIF(Fields!OrderStatus.Value="Discontinued", DateDiff("d",Fields!OrderStartTime.Value, Fields!DiscontinueTime.Value)
)
)
=Switch(Fields!OrderStatus.Value="Active",
DateDiff("d",Fields!OrderStartTime.Value, "Now"()),
Fields!OrderStatus.Value="Discontinued",
DateDiff("d",Fields!OrderStartTime.Value, Fields!DiscontinueTime.Value),
)
You are missing the third argument for your second iif statement (in this case, it'll be {Nothing}. This should work:
=IIF(Fields!OrderStatus.Value="Active",DateDiff("d",Fields!OrderStartTime.Value,Today()),IIF(Fields!OrderStatus.Value="Discontinued",DateDiff("d",Fields!OrderStartTime.Value,Fields!DiscontinuedTime.Value),Nothing))
I'm trying to make a query using a calculation with Date().
I have a field named [Currentordue] and a field named [duedate]. What I'm trying to accomplish is making a query to limit the results by "if [currentordue] equals "due" or if [duedate] minus today's date is less than 30 days."
I've tried a few different ways but always seem to end with either an error or with no results showing (which would be an error as well since I know there are fields that are due).
Any and all help would be appreciated.
Here is a way to use two different date conditions:
SELECT Table1.Currentordue, Table1.duedate, DateDiff("d",[duedate],Date()) AS Expr1
FROM Table1
WHERE (((DateDiff("d",[duedate],Date()))<30)) OR (((Table1.Currentordue)=[duedate]));
I am trying to write an expression in SSRS which counts only specific data using IIF. I found the following solution:
=Sum(IIF(Fields!Program.Value = "FC", Fields!QuantityToShip.Value, 0))
The code above works but only when there is ONE dataset, while I have several.
Here is the code I wrote:
=Count(IIF(Fields!Mgroup.Value,"DataSet1"=303,1,0))
I get the aggregation error:
Textbox refers directly to the field ‘Mgroup’ without specifying a dataset aggregate
I added a sum:
=Count(IIF(Sum(Fields!Mgroup.Value,"DataSet1")=303,1,0))
Still getting the same error.
Why is that?
What can I put instead of Sum? All I need is to count how many groups named 303 I have.
The expression you used has some sintax errors. The Count function only aggregate from the scoped Dataset.
Try this:
=LookupSet(303,Fields!Mgroup.Value,Fields!Mgroup.Value,"DataSet1").Length
Let me know if this helps you.
I am creating a report that will sum up all subtotal per MaterialNo/Color/Quality/Size.
Here's my sample report:
Computation will be GrandTotal = sum(Subtotal)
I am using =Sum(Fields!TOTAL_CTN.Value) but the result is 12.
Is there a way to compute using like =sum(subtotal_TextBoxName)?
I'm still not 100% sure of your underlying data and business logic, but here's one approach that might help.
I'm working off the following sample data:
Based on what your description above, it sounds like you have something similar to:
Which gives results:
It seems that you don't actually want to Sum TOTAL_CTN, rather this should be the same for every MaterialNo with the Sum only applied in the Grand Total.
As such you can change the Sub Total aggregation to Max and, since you're using Report Builder 3.0, you can then take the Sum of the group level aggregation values. The report will look like this:
Where the Grand Total expression is:
=Sum(Max(Fields!TOTAL_CTN.Value, "MaterialNoMax"))
In this expression MaterialNoMax refers to the name of the Row Group (based on MaterialNo in my example).
This gives your desired results:
The key here is thinking about what aggregation gets applied at each level and how these roll up to the end total.