Showing posts with label amount. Show all posts
Showing posts with label amount. Show all posts

Friday, February 24, 2012

Calculations in Database

I have a procedure that is performing a calculation and returning a amount, how do I store or save that amount and use it in different procedure to perform another calculationYou can simply store the value in a temporatry table.|||

Quote:

Originally Posted by debasisdas

You can simply store the value in a temporatry table.


how does one create a temporary table|||Hi,

maybe I am not understanding this but I would ask why you want to save a derived value - why not just call the first calculation procedure from the second then your data is guaranteed to be an acurate reflection of what is on the database at the time of the query..

Just my thoughts..

Regards Purple|||Yes that will be a better option.|||Thank you all, it worked out perfectly. I tried Purples advice and it was exactly what was needed. Thanks again|||Hi hopechirume,

I am pleased we were able to assist - look forward to seeing you around again soon.

Regards Purple

Thursday, February 16, 2012

Calculation between rows in one field

Hi,
I need to do a calculations on an amount field between rows in one field in
SQL Server 2000, i.e., (current_amount - previous_amount/previous_amount).
Let's say we have the following:
Quarter Amount
Q1 200000
Q2 150000
Q3 125000
Q4 75000
I really appreciate your help,
SKuntested.. but it should be in these lines. Hope this helps :)
select a. quarter, a.amount, (a.amount-b.amount)/a.amount
from table1 a left outer join table 1 b
on cast(right(a.quarter,1) as int) - cast(right(b.quarter),1) = 1|||change in the logic...
select a. quarter, a.amount, (a.amount-b.amount)/isnull(b.amount,1)
from table1 a left outer join table 1 b
on cast(right(a.quarter,1) as int) - cast(right(b.quarter),1) = 1|||Thank you so much for your reply! You saved me a lot of time and headache
for a project shortly due! :)
I made minor adjustments as below and it worked!
select a. quarter, a.amount, (a.amount-b.amount)/b.amount as diff
from table4 a left outer join table4 b
on cast(right(a.quarter,1)as int) - cast(right(b.quarter,1)as int) = 1
"Omnibuzz" wrote:

> untested.. but it should be in these lines. Hope this helps :)
> select a. quarter, a.amount, (a.amount-b.amount)/a.amount
> from table1 a left outer join table 1 b
> on cast(right(a.quarter,1) as int) - cast(right(b.quarter),1) = 1|||Better logic!
Thanks!
"Omnibuzz" wrote:

> change in the logic...
> select a. quarter, a.amount, (a.amount-b.amount)/isnull(b.amount,1)
> from table1 a left outer join table 1 b
> on cast(right(a.quarter,1) as int) - cast(right(b.quarter),1) = 1|||if you are looking no further, please mark the question as answered so that
the experts don't look at it as an unanswered question.|||Would you also know what is the best way to do this if the quarter and the
amount fields were in separate tables?
"Omnibuzz" wrote:

> if you are looking no further, please mark the question as answered so tha
t
> the experts don't look at it as an unanswered question.
>|||how will the quarter and amount fields be joined?
can you give an example with data?
"SK" wrote:
> Would you also know what is the best way to do this if the quarter and the
> amount fields were in separate tables?
>
> "Omnibuzz" wrote:
>|||This is what I had to get the two fields (quarter & amounts) that I needed
for calculations.
select SSO_DATES.QUARTER, SUM(SSO.AMOUNT) as AMOUNT
from SSO INNER JOIN SSO_DATES
ON SSO.SSO_ID=SSO_DATES.SSO_ID
where SSO.STATUS='8'
group by SSO_DATES.QUARTER
order by SSO_DATES.QUARTER
What would be the best way to combine/merge this with the query for
calculations given earlier?
Should I use a subquery of some sort?
"Omnibuzz" wrote:
> how will the quarter and amount fields be joined?
> can you give an example with data?
> "SK" wrote:
>|||This is one option in SQL Server 2000
select a. quarter, a.amount, (a.amount-b.amount)/isnull(b.amount,1)
FROM
(
select SSO_DATES.QUARTER, SUM(SSO.AMOUNT) as AMOUNT,
from SSO INNER JOIN SSO_DATES
ON SSO.SSO_ID=SSO_DATES.SSO_ID
where SSO.STATUS='8'
group by SSO_DATES.QUARTER
order by SSO_DATES.QUARTER
) AS A LEFT OUTER JOIN
(
select SSO_DATES.QUARTER, SUM(SSO.AMOUNT) as AMOUNT,
from SSO INNER JOIN SSO_DATES
ON SSO.SSO_ID=SSO_DATES.SSO_ID
where SSO.STATUS='8'
group by SSO_DATES.QUARTER
order by SSO_DATES.QUARTER
) AS B
on cast(right(a.quarter,1) as int) - cast(right(b.quarter),1) = 1
-- another option is to use a table variable like this
declare @.table1 table(QUARTER int, amount int)
insert into @.table
select SSO_DATES.QUARTER, SUM(SSO.AMOUNT) as AMOUNT,
from SSO INNER JOIN SSO_DATES
ON SSO.SSO_ID=SSO_DATES.SSO_ID
where SSO.STATUS='8'
group by SSO_DATES.QUARTER
order by SSO_DATES.QUARTER
Which is better depends on how your system is configured. whether it can
take more IO operations or memory intensive ops and also on the number of
rows returned by the subquery. The way I see it, there should only be at the
max 4 rows returned. So you can go for the first option.
If you are using SQL Server 2005, you can use CTE.
Both options given above are untested. written from home.
Hope this helps.

Tuesday, February 14, 2012

Calculating Quarters for a Forcasting Report

I am writting a query for a forcasting report and I am having a problem
figuring out how to calculate the amount of quarters that a certain
contract spans. I need to calculate the total quarters and then divide
the total contract by that quarter total to get the a single quarter
value. Then calculate the prior total and future total for the quarters
which do not fall within the fiscal year. Here's an example:
I have a contract that is worth $12,000
It's start date is 11.1.2005
It's end date is 8.31.2007
First I need find out how many quarters are in the time span from
11.1.2005 to
07.31.2007
Then I have to calculate the pre forcasted year totals, the forcasted
totals, and the post forcasted totals
(There are 4 quarters in the forecasted year + 1 prior quarter + 3
future quarters)
So, in the sample I provided there are 8 quarters that fall within the
data range.
Each quarters value would be 12,000/8 or $1500. So my report should
look something like this.
Prior Q1 Q2 Q3 Q4 Future
---
$1500 $1500 $1500 $1500 $1500 $4500
Any ideas? Thanks in advance for any help on this matter.
"Claude" wrote:

> I am writting a query for a forcasting report and I am having a problem
> figuring out how to calculate the amount of quarters that a certain
> contract spans. I need to calculate the total quarters and then divide
> the total contract by that quarter total to get the a single quarter
> value. Then calculate the prior total and future total for the quarters
> which do not fall within the fiscal year. Here's an example:
> I have a contract that is worth $12,000
> It's start date is 11.1.2005
> It's end date is 8.31.2007
> First I need find out how many quarters are in the time span from
> 11.1.2005 to
> 07.31.2007
> Then I have to calculate the pre forcasted year totals, the forcasted
> totals, and the post forcasted totals
> (There are 4 quarters in the forecasted year + 1 prior quarter + 3
> future quarters)
> So, in the sample I provided there are 8 quarters that fall within the
> data range.
> Each quarters value would be 12,000/8 or $1500. So my report should
> look something like this.
>
> Prior Q1 Q2 Q3 Q4 Future
> ---
> $1500 $1500 $1500 $1500 $1500 $4500
> Any ideas? Thanks in advance for any help on this matter.
>
Build calendar type table that houses Begin_Qtr_Date, End_Qtr_Date, YYYY_Q
i.e. 19800101 , 19800331 , 1980-1
19800401 , 19800630 , 1980-2
from earlier (make sure you go back far enough to cover all past contracts),
then estimate length of system life, then add 20-30 years?.(and for good
measure, write s_proc to notify dba when calendar is about to run out - or
have s_proc insert data 10 more years every 10 years ?).
Count rows in the table that have dates that fall into qtrs (as long as you
do not have to calculate partial qtrs ?) qtrly_amt = contract_amt/qtr_count.
display headers can be as easy as 1980-1 , 1980-2, 1980-3 etc or repplace
headers comparing dates again for past and future. calc prior and future by
qtrly_amt * qtrs.
Hope this helps.|||I was actually looking for a way to do this without a calendar
table...but thanks for your help. This is a report to be used in
Microsoft CRM 3.0|||If you have 2005, you can do a bunch of quarter stuff with my TDateRange
UDT. I don't fully understand your requirements, but here is some sample:
-- This is assuming your first fiscal month is 11. Change as needed.
declare @.dr TDateRange
set @.dr = '11/1/2005-07/31/2007'
select @.dr.NumberOfQuarters(11) as NumQuarters, @.dr.QuarterNumber(8)
set @.dr = TDateRange::GetQuarterByDate('11/1/2005', 11)
declare @.end datetime
set @.end = '7/31/2007'
while 1 = 1
begin
select @.dr.ToString()
if ( @.dr.EndDate >= @.end )
break
set @.dr = TDateRange::GetQuarterByDate(@.dr.AddMonths(3).StartDate, 11)
end
--Output
7 2
11/1/2005 12:00:00 AM - 1/31/2006 11:59:59 PM
2/1/2006 12:00:00 AM - 4/30/2006 11:59:59 PM
5/1/2006 12:00:00 AM - 7/31/2006 11:59:59 PM
8/1/2006 12:00:00 AM - 10/31/2006 11:59:59 PM
11/1/2006 12:00:00 AM - 1/31/2007 11:59:59 PM
Here is the lib url:
http://channel9.msdn.com/ShowPost.aspx?PostID=147390
--
William Stacey [MVP]
"Claude" <cg1970_1@.yahoo.com> wrote in message
news:1138146409.222812.312890@.g44g2000cwa.googlegroups.com...
|I was actually looking for a way to do this without a calendar
| table...but thanks for your help. This is a report to be used in
| Microsoft CRM 3.0
||||
"Claude" wrote:

> I was actually looking for a way to do this without a calendar
> table...but thanks for your help. This is a report to be used in
> Microsoft CRM 3.0
>
These calcs should be done outside of sql, but here you go. hopefully this
makes sense.
declare @.stdate datetime
declare @.eddate datetime
set @.stdate = '01/01/05 12:05 AM'
set @.eddate = '10/05/06 13:04 PM'
declare @.totalmonths int
set @.totalmonths = datediff(mm,@.stdate,@.eddate)
select @.totalmonths
declare @.stmonth int
declare @.edmonth int
set @.stmonth = month(@.stdate)
set @.edmonth = month(@.eddate)
declare @.stmonthvar int
declare @.edmonthvar int
set @.stmonthvar = CASE WHEN (@.stmonth in (1,4,7,10)) THEN '2'
WHEN (@.stmonth in (2,5,8,11)) THEN '1'
ELSE '0'
END
set @.edmonthvar = CASE WHEN (@.edmonth in (3,6,9,12)) THEN '2'
WHEN (@.edmonth in (2,5,8,11)) THEN '1'
ELSE '0'
END
set @.totalmonths = (@.totalmonths - @.stmonthvar - @.edmonthvar)
declare @.totalqs int
set @.totalqs = ((@.totalmonths/3)+2)
select @.totalqs|||>> was actually looking for a way to do this without a calendar table.<<
Why? SQL is based on tables, not procedural code.

Sunday, February 12, 2012

calculating Grand Total in table footer from Group Totals

Hi All,
I have a report with one group. In the group footer
there is a TextBox ( name: txtTotal) that displays a total dollar
amount for that group. I would like to show a Grand Total dollar amount
in the table footer of the report. So
the Grand Total dollar amount would ideally be a sum of the group
footer
dollar amount.
In the table footer I tried to calculate the grand total in following
way:
=Sum (ReportItems!txtTotal.Value)
but I had following errors:
1. Aggregate functions can be used only on report items contained in
page
headers and footers.
2. Report item expresssions can only refer to other report items within
the
same grouping scope or a containing grouping scope.
Can anybody know how to solve this...
Any help is appreciated.
Thanks,
Munny.You are thinking in terms of the summing the control. You want to be summing
the dataset. The best thing to do in this case is do not create the
expression by hand but use the expression builder.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"munnyAnu" <dkanumolu@.gmail.com> wrote in message
news:1166455738.086451.247430@.f1g2000cwa.googlegroups.com...
> Hi All,
> I have a report with one group. In the group footer
> there is a TextBox ( name: txtTotal) that displays a total dollar
> amount for that group. I would like to show a Grand Total dollar amount
> in the table footer of the report. So
> the Grand Total dollar amount would ideally be a sum of the group
> footer
> dollar amount.
> In the table footer I tried to calculate the grand total in following
> way:
> =Sum (ReportItems!txtTotal.Value)
> but I had following errors:
> 1. Aggregate functions can be used only on report items contained in
> page
> headers and footers.
> 2. Report item expresssions can only refer to other report items within
> the
> same grouping scope or a containing grouping scope.
> Can anybody know how to solve this...
> Any help is appreciated.
>
> Thanks,
> Munny.
>|||Thanks Bruce...
But I am not clear abount using expression builder instead of wrinting
expression.
Can you please give me detailed info.
Bruce L-C [MVP] wrote:
> You are thinking in terms of the summing the control. You want to be summing
> the dataset. The best thing to do in this case is do not create the
> expression by hand but use the expression builder.
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "munnyAnu" <dkanumolu@.gmail.com> wrote in message
> news:1166455738.086451.247430@.f1g2000cwa.googlegroups.com...
> > Hi All,
> >
> > I have a report with one group. In the group footer
> > there is a TextBox ( name: txtTotal) that displays a total dollar
> > amount for that group. I would like to show a Grand Total dollar amount
> > in the table footer of the report. So
> > the Grand Total dollar amount would ideally be a sum of the group
> > footer
> > dollar amount.
> >
> > In the table footer I tried to calculate the grand total in following
> > way:
> > =Sum (ReportItems!txtTotal.Value)
> >
> > but I had following errors:
> >
> > 1. Aggregate functions can be used only on report items contained in
> > page
> > headers and footers.
> >
> > 2. Report item expresssions can only refer to other report items within
> > the
> > same grouping scope or a containing grouping scope.
> >
> > Can anybody know how to solve this...
> >
> > Any help is appreciated.
> >
> >
> > Thanks,
> > Munny.
> >|||When you do a right mouse click, expression it brings up the expression
editor. Depending on whether you use RS 2000 or 2005 it is a little
different. What you want should look like this:
=sum(Fields!<your fieldname here>.Value)
Note that the above will work regardless of whether it is in a group footer
or table footer. It provides the sum based on the scope of the grouping.
Also note that it is not the name of the control, it is referencing the
fieldname of the dataset.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"munnyAnu" <dkanumolu@.gmail.com> wrote in message
news:1166458481.696297.200910@.73g2000cwn.googlegroups.com...
> Thanks Bruce...
> But I am not clear abount using expression builder instead of wrinting
> expression.
> Can you please give me detailed info.
> Bruce L-C [MVP] wrote:
>> You are thinking in terms of the summing the control. You want to be
>> summing
>> the dataset. The best thing to do in this case is do not create the
>> expression by hand but use the expression builder.
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>> "munnyAnu" <dkanumolu@.gmail.com> wrote in message
>> news:1166455738.086451.247430@.f1g2000cwa.googlegroups.com...
>> > Hi All,
>> >
>> > I have a report with one group. In the group footer
>> > there is a TextBox ( name: txtTotal) that displays a total dollar
>> > amount for that group. I would like to show a Grand Total dollar amount
>> > in the table footer of the report. So
>> > the Grand Total dollar amount would ideally be a sum of the group
>> > footer
>> > dollar amount.
>> >
>> > In the table footer I tried to calculate the grand total in following
>> > way:
>> > =Sum (ReportItems!txtTotal.Value)
>> >
>> > but I had following errors:
>> >
>> > 1. Aggregate functions can be used only on report items contained in
>> > page
>> > headers and footers.
>> >
>> > 2. Report item expresssions can only refer to other report items within
>> > the
>> > same grouping scope or a containing grouping scope.
>> >
>> > Can anybody know how to solve this...
>> >
>> > Any help is appreciated.
>> >
>> >
>> > Thanks,
>> > Munny.
>> >
>|||Bruce,
Thanks for your clarification.
I tried this. Bur the problem is I am getting sum of that filed value
from all records.
If I have a 5 records for Batch_1 with same total value,I dont want get
all records total.
I am displaying that "Field!total.Value" in group header.I want to get
this group header value.
Likewise if I have 3 Batches_1,2,3 with values (Field!total.value)
1200,500,100 then I want show the total of these three values (1800) in
table footer.
if you know how to solve this please let me know.
Thanks,
Muny|||The table footer should be all the records isn't it?
Why wouldn't it be the sum of the table value?
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"munnyAnu" <dkanumolu@.gmail.com> wrote in message
news:1166474761.054878.176140@.n67g2000cwd.googlegroups.com...
> Bruce,
> Thanks for your clarification.
> I tried this. Bur the problem is I am getting sum of that filed value
> from all records.
> If I have a 5 records for Batch_1 with same total value,I dont want get
> all records total.
> I am displaying that "Field!total.Value" in group header.I want to get
> this group header value.
> Likewise if I have 3 Batches_1,2,3 with values (Field!total.value)
> 1200,500,100 then I want show the total of these three values (1800) in
> table footer.
> if you know how to solve this please let me know.
> Thanks,
> Muny
>

Calculating Average in SubTotals

I have a report that subtotals by games. For example, one game is played 16528 times and the amount of money played is $19443.75. The correct subTotal average for the game is $1.18, but SQL Reports returns $1.09. I tried various ways of calculating the subTotal average, but with the same results. Is this an issue with SQL Reporting, or does anyone know of a method for calculating a subTotal average? Thank you.

The Average aggregate in Reporting Services works very similar to the Avg aggregate in SQL. Only values that are different than NULL contribute to the average, e.g.: the average for the following set { 2, 3, 2, NULL, 3 } is 10/4 = 2.5, instead of 10/5 = 2.0.

Note: you could convert NULL into 0 either in the query or based on a RDL expression if you want the behavior that NULLs are treated as zero.

-- Robert

Calculating a Local Currency Value

I've written an Sql statement to extract the Currency Amount and the currency rate and I want to calculate the Amount in Local Currency.

If the currency amount is in the local currency the Currency rate value returned is 0. I have used a case statement to convert the 0 to 1. (is there
easier way)

But I now can't calculate my Local amount value because of the way I have converted the currency rate.

Select IH.Amount, 'Currency Factor' = CASE
when
IH.[Currency Factor] = 0 then 1
else IH.[Currency Factor]
end,

what way should I have written this?Ya lost me...

How about some sample data and what the expected results should be...DDL would be useful as well...|||Geraldine Solved it ........

CASE
WHEN CurFctr = 0 THEN Amount
ELSE CurFctr * Amount
END AS Amount

Thanks Geraldine ... again|||Well...congrats...

Who's Geraldine?|||Wasn't Geraldine Sanford's wife?

Friday, February 10, 2012

Calculated Members Problem

1. I got the price and the qty in the data source. when I create the
calculated member Amount = Qty * price, I found out the total is equal to the
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?
"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price

> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti
|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:

> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>

Calculated Members Problem

1. I got the price and the qty in the data source. when I create the
calculated member Amount = Qty * price, I found out the total is equal to th
e
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price

> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:

> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
>
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>

Calculated member with measure and dimension

Hi,

We have a little problem with our calculated member... in our table we have the total amount of a sale in 2 different currencies (US and CAN).

In another field we have the currency (1 being can, 2 being US)

Now I need to create a measure that will give me all the amount in CAN money and one in US money (depending on how users want to view the cube) but it's not working since my Exchange rate is not a measure and the type of currency isn't either, so the system isn't entering in my case.

I tried to do something like this :

case [Probill General].[Payeur Fund type]

when 1

then ([Measures].[Probill Total] * [Probill General].[Us Exch Rate])

when 2

then ([Measures].[Probill Total])

end

But it doesn't enter in the cases and it gives me an empty data field when I put it in the cube.

Any idea on how to bypass that problem?

Thanks,

Jason

Hello. One problem with your Case statement is that you do no write this in the TSQL way.

Instead try something like:

Case When [Probill General].[Payeur Fund type] = 1

Then [Measures].[Probill Total] * [Probill General].[Us Exch Rate])

Else [Measures].[Probill Total]

End

A good Blog post about currency conversion you can find here: http://blogs.conchango.com/christianwade/archive/2006/08/24/Currency-Conversion-in-Analysis-Services-2005.aspx

HTH

Thomas Ivarsson

|||

Didn't work...

I went to that page and tried to create something based on that which didn't really solved my problem.

I think the real problem in my cube lies in the fact that my table has total that are both in canadian funds and us funds... all the solution on the web are to convert a full us fund (or other) to another currency but I can't seem to find anything where I can just transform or not an amount into a currency based on a dimension field...

I talked to my boss and she wants everything in Canadian funds, which means that IF my "[Probill General].[Payeur Fund type] = 1" then "[Measures].[Probill Total]" stays the same, but if it's "[Probill General].[Payeur Fund type] = 2" then it has to be "[Measures].[Probill Total] / [Probill General].[Us Exch Rate]" .

Any idea on how you can apply that in a cube?

Thanks

|||

With only two currencies the simple solution is to solve this problem in the ETL-process(not inte cube), when you load your data mart/data warehouse.

You will need a currency table with dates and currencies. If you have the currency code in the fact table when you load data, you join the date and the currency with your currency table.

If the requirement is that all values should be i CAD you only need to keep the exchange rate for CAD against your incoming currencies.

HTH

Thomas Ivarsson

Calculated member with measure and dimension

Hi,

We have a little problem with our calculated member... in our table we have the total amount of a sale in 2 different currencies (US and CAN).

In another field we have the currency (1 being can, 2 being US)

Now I need to create a measure that will give me all the amount in CAN money and one in US money (depending on how users want to view the cube) but it's not working since my Exchange rate is not a measure and the type of currency isn't either, so the system isn't entering in my case.

I tried to do something like this :

case [Probill General].[Payeur Fund type]

when 1

then ([Measures].[Probill Total] * [Probill General].[Us Exch Rate])

when 2

then ([Measures].[Probill Total])

end

But it doesn't enter in the cases and it gives me an empty data field when I put it in the cube.

Any idea on how to bypass that problem?

Thanks,

Jason

Hello. One problem with your Case statement is that you do no write this in the TSQL way.

Instead try something like:

Case When [Probill General].[Payeur Fund type] = 1

Then [Measures].[Probill Total] * [Probill General].[Us Exch Rate])

Else [Measures].[Probill Total]

End

A good Blog post about currency conversion you can find here: http://blogs.conchango.com/christianwade/archive/2006/08/24/Currency-Conversion-in-Analysis-Services-2005.aspx

HTH

Thomas Ivarsson

|||

Didn't work...

I went to that page and tried to create something based on that which didn't really solved my problem.

I think the real problem in my cube lies in the fact that my table has total that are both in canadian funds and us funds... all the solution on the web are to convert a full us fund (or other) to another currency but I can't seem to find anything where I can just transform or not an amount into a currency based on a dimension field...

I talked to my boss and she wants everything in Canadian funds, which means that IF my "[Probill General].[Payeur Fund type] = 1" then "[Measures].[Probill Total]" stays the same, but if it's "[Probill General].[Payeur Fund type] = 2" then it has to be "[Measures].[Probill Total] / [Probill General].[Us Exch Rate]" .

Any idea on how you can apply that in a cube?

Thanks

|||

With only two currencies the simple solution is to solve this problem in the ETL-process(not inte cube), when you load your data mart/data warehouse.

You will need a currency table with dates and currencies. If you have the currency code in the fact table when you load data, you join the date and the currency with your currency table.

If the requirement is that all values should be i CAD you only need to keep the exchange rate for CAD against your incoming currencies.

HTH

Thomas Ivarsson