My report layout is linked to a stored procedure in SQL, which returns data regarding inventory from our SAP B1 system. This identifies appropriate Minimum and Maximum stock holding values.
I draw in several fields into calculated fields. A pair of parameter fields input a 'no. of periods' value (such as 6 months) and specify an item group from the list in SAP. I currently get the sum total of items invoiced out, minus the sum total of credited in all the way back to record one in the DB.
I need to be able to get a new sales total which is sum total of items invoiced out minus sum total of credits in, divided by the no. of periods value to get a new average sales value. but I simply can't think about how to go about creating the field.
How can I get the desired behavior?
Related
Looking to create pricing groups bases on multiple criteria. Each group could have multiple items within the group. I'm struggling with the autocreation the naming of each group. I estimate there should be about 6.5K pricing groups out of 14K items.
Below is the criteria -
QTY per case - is the number of bottles in a case
Size - size of the bottle
Family Brand - contains a group of like items
Code - CS1 - This is my unique code for each group that contains each of the above and lowest possible case price.
enter image description here
The "Thinking" column is how I want each group to look, but how do I do this with 14K items quickly?
If I understood correctly your pricing group name consists of two parts: a simple combination of columns and a "special" column, that should be counted.
Part 1 is simple: =C2&"-"&B2&"-"&A1&"-"
To make Part 2 easier you could sort, sorting fields Part 1, CODE-CS1.
After have done this you could use helping columns. If Part 1 is in column x and code-CS1 in column y you could find a formula for
Part 2 (column z): ="T"&IF(X1=X2;IF(Y1=Y2;Z1;Z1+1);1)
That means: If Part 1 is changing your counter starts with T1, if not so if your CODE CS1 changes, it counts, if not, so it keeps last number.
the result code would be =X2&Z2
It is untested and I use german excel, maybe the code doesn't work without any adaption, but in general it should work
So I've got a pretty simple view that looks like this:
Location Month DelRec Warehouse_Number Code Value
Canada November Deliveries Warehouse1 C 11041.2
Canada November Deliveries Warehouse 2 C 0
Canada November Receipts Warehouse 3 C 0
USA November Receipts Warehouse_10 H 2543.2
Ultimately, what I would like to create is a matrix in SSRS that uses 'Code' as a dynamic column name and grouping by DelRec and Location (expanding the number of columns for each code available for that grouping). Easy enough, right? Looks something like this:
Now the next step I've got is to do some conditional summing on these values, which has got me stymied. In particular, for example, in the below data, for Canada, Deliveries need to be summed up together (Warehouse 1 and 2), and then the total of those two subtracted from Receipts (in this case, just Warehouse 3). Ostensibly, this would look something like this:
The problem is, I can't figure out how to do conditional summing (i.e. sum deliveries and subtract them from the sum of receipts), especially when dynamic columns are involved (because we don't know what warehouse numbers might come in future data).
In addition, I actually need a column that has the Total Deliveries and Total Receipts, which is causing me even further difficulty.
Anybody have any idea of how to do this? The result should look something like this:
I've created a a pastebin
with some representative SQL data for insert if anyone would actually like to try this out.
As I understand essentially "Receipts" are credits and can be treated as a positive amount and "Deliveries" are debits and can be treated as a negative amount. To get the correct total you could replace the Sum expression in the bottom right of the matrix with
=Sum(IIF(Fields!DelRec.Value="Receipts",Fields!Value.Value,-1 * Fields!Value.Value))
To get a total line for deliveries and receipts you need to either right click on Warehouse_Number in the matrix, then click on Add Total then click on After.
Alteratively you can right click on Warehouse_Number in the Row Groups and add total from there.
The matrix should now look like this
The report should now look like this
Right clicking on Code in the matrix then "Add Total" -> "After" will add Row Totals as a new column. Note that this will only total "Receipt" or "Deliveries" by Location as the report is grouped Location then DelRec then Warehouse. You could achieve a Receipt Grand Total through either adding extra rows at the bottom of the matrix, or better in my opinion is another table only grouped by DelRec to calculate the DelRec Grand Totals.
I have a pivot table
Year and Week are Rows. Orders and Return Loaded are calculations based on sum(OrderSum) and sum(Reutilized) respectively
What I need is a third calculation based on the division of Return Loaded and Orders. This is to show what % Reutilized represent of the total orders. In the first case would be 14.04% (8 represent 14% of 57).
That type of calculation is not possible within the pivot itself. There are two general workarounds.
You can setup the calculation in the underlying data in a way that lets you pull the value through to the pivot. I would need to know how that is laid out to explain further.
You can create an additional table where you read the values from your pivot using GetPivot() formulas and then do your calculation there. You would manually add new rows here for new weeks.
I am trying to calculate a measure based on an attribute in a dimension I have. Never done this before and keep getting errors so thought I would reach out for help. One of my dimensions is an Items dimension and it holds an attribute called Contribution Cost. I also have a measure on my fact table called Net Sales Amount. If there is no cost on a specific item, I want to calculate a Contribution Margin off a percentage of Net Sales, otherwise I want it to simply take the net sales minus the contribution cost. This is what I wrote but could someone help me?
CREATE MEMBER CURRENTCUBE.[Measures].[Contribution Profit]
AS CASE WHEN SUM([Items].[Contirbution Profit]) = 0 THEN SUM(measures.[Net Sales Amount2]) * .6
ELSE SUM(measures.[Net Sales Amount2]) - SUM([Items].[Contirbution Cost]) END,
FORMAT_STRING = "$#,##0;$#,##0",
VISIBLE = 1 ;
My model TicketBuyer columns include ticket_buyer name and number_of_tickets purchased. I want to randomly select a winning ticket. I think my preference is to create another model (SelectTable) that has the ticket_buyer name replicated over the number of rows equal to the number_of_tickets purchased, thereby giving equal weight to each record. I can then just run a simple sort and pick the first record in the new table. I am having trouble auto creating the table with the correct number of rows for each ticket_buyer. Of course, there may be a more eloquent/ efficient way to do this as well. Advice is much appreciated.
If speed isn't a problem you can do it without creating any extra data structures.
Find the maximum number_of_tickets bought by anyone
Randomly select a ticket buyer
Do another draw, with a number_of_tickets / max_number_of_tickets chance of them becoming the winner
If they fail the second draw, randomly select another ticket buyer and repeat the process until someone wins
Unless there is some crazy distribution like one person buys a million tickets and everyone else buys one, this shouldn't take too long.
Pseudo-code:
max_tickets = max(table:number_of_tickets)
while true do:
// select a random buyer
buyer = select random row from table
// assume random(n) returns an integer number from 0 to n - 1 inclusive:
if random(max_tickets) < buyer.number_of_tickets then
return buyer // we have a winner
end