How to count value with changing margin in WEBI? - business-objects

​Hi Guys,
it sounds easy but it doesn't... Customer got several invoices in specific periods (months).
We want to calculate the final amount (total+margin). The problem is that margin is changing during the periods.
​I want to get 7142,76 in one cell (for summary). As you can see it's feasible in table but not in single formula as I am getting #MULTIVALUE
I guess the rootcause is margin which variable is quite simple:
=If([Doc Year]="2022" And [Doc Period]>=1 And [Doc Period]<=2) Then 0 Else If ([Doc Year]="2022" And [Doc Period]>2 And [Doc Period]<7) Then 4,5 Else 10
Thanks
The 6835,18 value is calcuated by:
​=Sum([Term Invoice Line Net Amount] ForAll ([Customer];[Doc Year];[Doc Period];[vMargin]))
​Cant figure out how to calculate total with margin...

Maybe someone will use my findings.
Finally I tried to focus just on counting the margin amount (307,58) and finally got it:
Sum([Term Invoice Line Net Amount]*[vMargin]/100)
Then final formula is:
=Sum([Term Invoice Line Net Amount] ForAll ([Customer];[Doc Year];[Doc Period];[vMargin]))+Sum([Term Invoice Line Net Amount]*[vMargin]/100)
and it works!
Previously I had #MULTIVALUE as I was counting amount with margin as below:
=Sum([Term Invoice Line Net Amount]*([vMargin]/100))
But the correct formula is:
=Sum([Term Invoice Line Net Amount]*[vMargin]/100)
small diffrence but crucial

Related

SUM expression with column and row scope

I work in lending and we are trying to get the percentages of purchases and refis to show for the months. The problem that I am having is that I cannot get the scope correct.
Here is the current list
Andhere are the row groups
I know this is definitely a scope issue - I just can't figure out a way to have it take into account the month and the year. I have had success with it doing the percent of the year value. I am trying to simply show the percent of purchases and Refis for a given month for a given year.
For example, If we have 60 purchases and 40 Refinances for January of 2019 - I want it to show 60% and 40%.
I have tried messing around with the row and columns groups every which way and I still cannot seem to figure it out. Any help would be largely appreciated.
= SUM(Fields!TOTALLOANAMT.Value, "Grouped_Loan_Purpose5") /
SUM(Fields!TOTALLOANAMT.Value, "App_Sent_Year1")
I have a fairly simple solution that you could use to avoid any headache involved with grouping. I would suggest simply using the values in the textboxes to calculate your percentages. You can just do something like the following.
=(ReportItems!PurchasesTextbox.Value / ReportItems!TotalTextbox.Value) * 100
=(ReportItems!RefinanceTextbox.Value / ReportItems!TotalTextbox.Value) * 100
Then you can just format as percentages and leave everything else alone.

SSRS Report SUM IF

Working on a ssrs report I ran into a problem.
In case that the Opening balance (the first row) is recorded as an Income, the Balance in the upper right corner
Should be reduced by the value shown in the "Income" cell for the Opening Balance row.
In case that the Opening Balance is recorded as Expenses the expression should stay as it is.
This is the expression for the Balance cell: =Sum(Fields!Income.Value-Fields!Expenses.Value)
Any help would be greatly appreciated :)
It looks to me like you need to take the balance, subtract the income and add the expenses from the row in your dataset that contains the description "opening balance...".
This could be achieved by using the initial balance calculation that you already have and doing a lookup to get the income/expense for the "opening balance..." line item based on the first 15 characters of the description ("Opening Balance"):
=Sum(Fields!Income.Value-Fields!Expenses.Value) - Lookup("Opening Balance", Left(Fields!Description.Value, 15), Fields!Income.Value, "DatasetName") + Lookup("Opening Balance", Left(Fields!Description.Value, 15), Fields!Expenses.Value, "DatasetName")
I'm guessing that this won't work out of the box and that you may have to test for nothing or COALESCE your database values and/or cast your fields to get this to work. Impossible to say exactly without seeing your actual dataset.

SSRS Group Footer - Expression to show a certain row from dataset

This is a report for Reps showing the customers sales for the previous day and the reps budget for the customer. So in my query I've already calculated the customer total, budget etc. which I managed to put into the report. The problem I have now is that the report's display is toggled so in the group footer I need to display the customer's total as well. I can not sum the column then it will include the budget. I need to input a expression, something like this:
=Tons WHERE ItemDesc = "Customer Total"
I have tried to google for a solution but all I can find is IIF statments. Is there anyway to do this?
Example:
You should be able to use something like this...
=SUM(IIF(Fields!ItemDesc.Value = "Customer Total", Fields!Tons.Value, 0))
All we are doing here is evaluating each row's ItemDesc, if it's "Customer Total" grab the Tons value if not grab 0... then sum all the results.
Thank you Alan Schofield but that did not work. After more searching I went with the lookup:
I added a second dataset with only the totals, then in the expresion for the footer I did the following:
= Lookup (Fields!Customer.Value,
Fields!Customer.Value,
Fields!Tons.Value,
"DataSet2")
This example helped me alot: http://www.sql-datatools.com/2015/07/lookup-functions-in-ssrs.html

SSRS percentage of a total with column groups

I apologize in advance if this is not enough info or if it is confusing (This is my first post to the forum and it's a little hard to explain what i'm trying to do). I have been researching this for a couple days now. This article comes really close to what I need, but this person did not have column groups, just a a single column with an output: SSRS percentage of a total.
Consider this layout and groups:
The idea is to provide the percentage of the total records per PrimaryPayor per Company and then break it out by Year-Month.
This expression:
=CountDistinct(Fields!ID.Value, "Primary_Payor") / CountDistinct(Fields!ID.Value, "Company")
Results in this output (The first image is my output, the second is the desired output):
As you can see, the percentages do NOT group by Year-Month, instead just provides the total percentage of IDs per Payor per Company and repeats it for every Year-Month column. How can I get the percent of Total IDs per payor, company, and month as it shows in the second result image?
After editing my question, I thought of something I hadn't tried.
If I just use =CountDistinct(Fields!ID.Value), this gives the total count for each payor, company, month, plus, I added a Total row.
Then, if I reference those textbox values (instead of trying to calculate the percentage on the fly) divided by the total row, I get my results. I just had to add a column inside of the column group. I should then be able to just Hide my "total" column and display only the percentages.
=ReportItems!Textbox50.Value / ReportItems!Textbox35.Value
Here is the output (with the total counts and then after hiding the "count" column):
Final Results
Try:
=CountDistinct(Fields!ID.Value) / CountDistinct(Fields!ID.Value, "Company")
I removed the Primary_Payor scope leaving the function calculate the count in the cell scope Primary_Payor and DOS_YrMo.
UPDATE:
=CountDistinct(Fields!ID.Value) / CountDistinct(Fields!ID.Value, "DOS_YrMo")
Let me know if this helps.

SSRS how to get a running total of inventory amounts IN and OUT from START DATE to END DATE?

i have a stored proc returning inventory amounts between a start and end date.
the QTY field shows on-hand inventory adjustments by date, either IN or OUT.
i have a "run balance" field that needs to show the total QTY each day. if the InOut field is 0, it's QTY in. if it's a 1, its QTY out. the values reflected in In and Out are coded that way.
EXAMPLE. if i start on 4/1/14 with 5216. then 1061 of product is made on 4/1/14 i need the run balance to take 5216 and add 1061 on the next line. the next line should read 6277 instead of 1061. then if some is shipped, take 6277 and subtract, and so on.
i tried the running value on QTY, but it just repeats the QTY. doesn't calculate anything.
=RunningValue(Fields!QTY.Value,Sum,"Details")
i tried to post an image of my report preview, but i don't have the reputation ;-)
any help would be MUCH appreciated.
EDIT: OK, i tried this code block:
= Switch(RunningValue(Iif(Fields!InOut.Value = 0, Fields!QTY.Value,0),Sum,"Details"),
RunningValue(Iif(Fields!InOut.Value = "1", Fields!RunBalance.Value - Fields!QTY.Value,0),Sum,"Details"))
and i am getting a 0 on the sum fields, and #Error on the subtraction fields. but, i think this is more the direction i need to go (i hope)....but i am still not getting it.
There are a couple of things to look at here.
First, you specify the Scope of "Details" in your RunningValue expression... By default this group will have no grouping value, i.e. each row in the dataset will be in its own group. Which means the RunningValue will only ever be applied to one row only. Change the Scope to "MyDataset" or Nothing, whatever is appropriate.
Secondly, you need to consider how the InOut field affects the RunningValue.
I have created a simple Dataset:
And a simple table:
The Balance expression is:
=RunningValue(IIf(Fields!InOut.Value = 0, Fields!QTY.Value, Fields!QTY.Value * -1)
, Sum
, Nothing)
You can see this changes the Scope from your original statement, and also applies a multiplier to QTY based on InOut.
Works OK for my sample data: