I am building a report in visual Studio and have various calculations for things like total etc.
I am now trying to find the percentage of two totals but I am struggling as it won't allow me to use 2 aggregate functions in my one expression.
The functions I have are:
=Sum(Fields!Quantity.Value, "AccruedHours") + Sum(Fields!Quantity.Value, "Services")
AND
=Sum(Fields!Quantity.Value, "AccruedHours") + Sum(Fields!Quantity.Value, "Services")
They are the same function but act for 2 different totals so in order to find out the percentage I have to divide both these functions by each other see below:-
=Sum(Fields!Quantity.Value, "AccruedHours") + Sum(Fields!Quantity.Value, "Services")/=Sum(Fields! Quantity.Value, "AccruedHours") + Sum(Fields!Quantity.Value, "Services")
can anyone suggest a better way to do this?
Many thanks,
You can use Val function
Simply try this
=Val(Sum(Fields!Quantity.Value, "AccruedHours") + Sum(Fields!Quantity.Value, "Services"))/Val(Sum(Fields! Quantity.Value, "AccruedHours") + Sum(Fields!Quantity.Value, "Services"))
I managed to figure it out in the end.
The way I did it was using the below code to reference the exact text boxes rather than trying to do seperate aggregate functions. This way I just had to do a divide on the two totals.
See below code:-
=(ReportItems!textbox20.Value) /
(ReportItems!textbox22.Value)
Thanks anyway for the suggestions to the original question.
Related
I will make this question and scenario as basic as possible since I have no background on programming. How do I make a script where all red will be multiplied by 5, yellow by 6 and blue by 7? The new measure will aggregate in grand total. I don't know what expressions to use. Just use [Product] for the colors and [Measure] for qty.
enter image description here
I dont understand yet the use of MEMBERS and other expressions as this is my first time to be on it. I tried
([Measure].[Quantity],[Product].&[Yellow])*6
but it will just multiply everything with 6. Maybe FILTERS? IIF? I just don't know how. The script will go a long way when I will apply it in our database. thanks!
I know you asked about doing this with excel, but if you were writing an MDX query you could do create a new measure and run the query like this:
WITH
member measures.[ColorQuantity] AS CASE WHEN [Product].[Product].currentmember.member_key = "Yellow" THEN measures.[Quantity] * 6
WHEN [Product].[Product].currentmember.member_key = "Blue" THEN measures.[Quantity] * 5
WHEN [Product].[Product].currentmember.member_key = "Red" THEN measures.[Quantity] * 2
ELSE measures.[Quantity] END
SELECT {
measures.[Quantity], measures.[ColorQuantity]
} ON 0,
Non EMPTY
{
[Product].[Product].[All].Children /// I dont know the FULL dimension AND hierarchy path you want TO use
} ON 1
FROM YourCubeName
This might help you get started.
I have been using
=Sum(Fields!Figure, "Dataset1")
+ Sum(Fields!Figure, "Dataset2")
Now this gives me a result in a text box.
However, i need to sum together the result from 4 different tablix datasets.
I have tried this below but as soon as i try to sum more that 2 datasets it errors.
=Sum(Fields!Figure, "Dataset1")
+ Sum(Fields!Figure, "Dataset2")
+ Sum(Fields!Figure, "Dataset3")
+ Sum(Fields!Figure, "Dataset4")
This gives me (#error). I am assuming i am missing some code somewhere but i have looked online and cant find anything anywhere.
Can anyone help?
Thanks
I'm fairly certain the field is ended with .value:
=SUM(Fields!TextBoxName.Value, "Dataset1")
+SUM(Fields!TextBoxName.Value, "Dataset2")
...
I am more or less new to VB.NET and I am trying to program a simple console application for a basic finance and savings calculation program.
I am having trouble with the Math.Log() function and I hope someone can help me to point out my
mistake/mistakes.
This is the values I need to get working (the brackets shows the values that actually should work but do not in my code):
Public Class basicSavingsPlaner
Private userTotalCost As Double (50,000.00)
Private userSaves As Double (3,451.47)
Private userAnnualRate As Decimal (0,08)
Private userMonths As Double (should be 10)
If I use my regular calculator (TI-82) I get the correct answer of userMonths which is 10, this is how I type it on my calculator (I switched the values from digits to the names of my Declarations):
(log(((userAnnualRate * userTotalCost)/userSaves)+1)/(log(1+userAnnual)) = 10.0029...
This is my attempt to recreate it for my VB.NET console application:
userMonths = ((Math.Log((userAnnualRate * userTotalCost) / userSaves) + 1) / (Math.Log(1 + userAnnualRate)))
In this case, userMonths's result is 14.9, which is wrong.
I would really appreciate if someone could help me, I have search here in this forum and on Google for days now.
// Televeinken
If you look closely at the statement from your TI-82 and compare it with your VB.Net code you will see that you have the statement grouped differently between the two. Try something like this(note the grouping of three brackets after the initial log statement instead of two):
userMonths = (Math.Log(((userAnnualRate * userTotalCost) / userSaves) + 1) / (Math.Log(1 + userAnnualRate)))
userMonths = 10.000008962349851
The problem is with the grouping expressions with brackets () that is you are executing different expressions with Math.Log and log.
if you change like this ((Log((userAnnualRate * userTotalCost) / userSaves) + 1) / (Log(1 + userAnnualRate)))
means it will also result in 14.9
OR you can make a change like
(Math.Log(((userAnnualRate * userTotalCost) / userSaves) + 1) / (Math.Log(1 + userAnnualRate)))
then both will result in 10.00
I have two datasets in Report Builder 3.0 with a similar field and I want to put a SUM of the number occurrences of a particular value in that common field across both datasets.
I've got an expression I'm using for each individual dataset:
=SUM(IIF(Fields!caseorigin.Value = "mail",1,0))
and
=SUM(IIF(Fields!cliorigin.Value = "mail",1,0))
But I can't seem to work out a way to sum the values from both datasets. I've tried:
=SUM(IIF((Fields!caseorigin.Value, "caseDS") = "mail",1,0)) + SUM(IIF((Fields!cliorigin.Value, "cliDS") = "mail",1,0))
Is there any way to make this work, or an alternative method?
Just looks like a syntax error here; when specifying a scope it should like something like:
=Sum(Expression, Scope)
Applying this to your example:
=SUM(IIF(Fields!caseorigin.Value = "mail",1,0), "caseDS")
+ SUM(IIF(Fields!cliorigin.Value = "mail",1,0), "cliDS")
Should work for you.
I'm trying to generate a new SharePoint list item directly using SQL server. What's stopping me is damn tp_DirName column. I have no ideas how to create this value.
Just for instance, I have selected all tasks from AllUserData, and there are possible values for the column: 'MySite/Lists/Task', 'Lists/Task' and even 'MySite/Lists/List2'.
MySite is the FullUrl value from Webs table. I can obtain it. But what about 'Lists/Task' and '/Lists/List2'? Where they are stored?
If try to avoid SQL context, I can formulate it the following way: what is the object, that has such attribute as '/Lists/List2'? Where can I set it up in GUI?
Just a FYI. It is VERY not supported to try and write directly to SharePoint's SQL Tables. You should really try and write something that utilizes the SharePoint Object Model. Writing to the SharePoint database directly mean Microsoft will not support the environment.
I've discovered, that [AllDocs] table, in contrast to its title, contains information about "directories", that can be used to generate tp_DirName. At least, I've found "List2" and "Task" entries in [AllDocs].[tp_Leaf] column.
So the solution looks like this -- concatenate the following 2 components to get tp_DirName:
[Webs].[FullUrl] for the web, containing list, containing item.
[AllDocs].[tp_Leaf] for the list, containing item.
Concatenate the following 2 components to get tp_Leaf for an item:
(Item count in the list) + 1
'_.000'
Regards,
Well, my previous answer was not very useful, though it had a key to the magic. Now I have a really useful one.
Whatever they said, M$ is very liberal to the MOSS DB hackers. At least they provide the following documents:
http://msdn.microsoft.com/en-us/library/dd304112(PROT.13).aspx
http://msdn.microsoft.com/en-us/library/dd358577(v=PROT.13).aspx
Read? Then, you know that all folders are listed in the [AllDocs] table with '1' in the 'Type' column.
Now, let's look at 'tp_RootFolder' column in AllLists. It looks like a folder id, doesn't it? So, just SELECT the single row from the [AllDocs], where Id = tp_RootFolder and Type = 1. Then, concatenate DirName + LeafName, and you will know, what the 'tp_DirName' value for a newly generated item in the list should be. That looks like a solid rock solution.
Now about tp_LeafName for the new items. Before, I wrote that the answer is (Item count in the list) + 1 + '_.000', that corresponds to the following query:
DECLARE #itemscount int;
SELECT #itemscount = COUNT(*) FROM [dbo].[AllUserData] WHERE [tp_ListId] = '...my list id...';
INSERT INTO [AllUserData] (tp_LeafName, ...) VALUES(CAST(#itemscount + 1 AS NVARCHAR(255)) + '_.000', ...)
Thus, I have to say I'm not sure that it works always. For items - yes, but for docs... I'll inquire into the question. Leave a comment if you want to read a report.
Hehe, there is a stored procedure named proc_AddListItem. I was almost right. MS people do the same, but instead of (count + 1) they use just... tp_ID :)
Anyway, now I know THE SINGLE RIGHT answer: I have to call proc_AddListItem.
UPDATE: Don't forget to present the data from the [AllUserData] table as a new item in [AllDocs] (just insert id and leafname, see how SP does it itself).