Solved

How do I create a formula column that will subtract two generated colums, from column grouping?

Posted on 2014-12-12
10
189 Views
Last Modified: 2014-12-23
I have a Matrix with a column grouping.
when running the report it creates two columns.
Column A     Column B

I need:

Column A     Column B      =Column A - Column B

I need to subtract Column B  from Column A somehow by referencing

I am having a problem with the formula where it only shows column A in the formula colum.

Please advise!!
0
Comment
Question by:rhservan
  • 5
  • 5
10 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40497890
Not enough information, for example,what is your data source and data set?
0
 

Author Comment

by:rhservan
ID: 40509005
Hope this helps!
Variance.rtf
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40509092
Are you saying that there is a varchar field called ACTUAL_BUDGET, which says "Actual" or "Budget", and there is a money field called SIGNEDDATA?
0
 

Author Comment

by:rhservan
ID: 40509226
Yes, Actual and budget is in a Category dimension which compares Actual dollars spent to Budget Dollars spent based on the money measure signeddata.
0
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 500 total points
ID: 40509286
Try this;

=sum(IIf([ACTUAL_BUDGET])="Actual",SIGNEDDATA,0)-sum(IIf([ACTUAL_BUDGET])="Budget",SIGNEDDATA,0)
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:rhservan
ID: 40511554
I crated a column inside the group and placed  formula in there.  When I ran the report it eroded with a scope problem.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40511601
Let's start slowly then. Please try the following, and tell me which formulas give an error or an unexpected result.

=sum(SIGNEDDATA)

=sum(IIf([ACTUAL_BUDGET])="Actual",1,0)



=sum(IIf([ACTUAL_BUDGET])="Actual",SIGNEDDATA,0)
0
 

Author Comment

by:rhservan
ID: 40512118
0
 

Author Comment

by:rhservan
ID: 40512135
UPDATE - Disregard previous above communication.

I moved the parentheses to the end.  Which gave more of a result. However, still not correct. I added the column outside of the group in the design, thinking it would give a single column in the result. But not. See attached file. 2 problems still exist:

1. Need a single column for the result
2. Need the subtraction to work correctly

=sum(IIf(Fields!ACTUAL_BUDGET.Value="Budget",Fields!SIGNEDDATA.Value,0))-
sum(IIf(Fields!ACTUAL_BUDGET.Value="Actual",Fields!SIGNEDDATA.Value,0))

GIVES ME THIS:
Result.rtf
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40514646
It depends how you inserted the column.

Start again with two columns, then right-hand click on the second column and select Insert Column - Outside Group - Right.

You can then insert this formula in the third column.

If you find this is not working, then instead of using a Matrix, use a Table, and do the grouping/pivotting in SQL instead of leaving it to SSRS.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PL/SQL query 14 51
Update foreign key reference after insert 9 36
Caste datetime 2 25
Report Builder 3.0 3 9
Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now