SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Tabular) DAX currency conversion multiple target values


Tabular) DAX currency conversion multiple target values

Author
Message
gfv1
gfv1
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 23
Hi All
I m novice in SSAS.
SSAS 2012 SP1 on W7 x64

I need to be able to convert all sums into reports into different currencies

http://www.sqlservercentral.com/blogs/salvoz-sql/2013/01/28/currency-conversion-in-tabular-model-using-dax/#comments
is good article but
Target Currency Dimension Table (optional)
I did not include this dimension in the tabular model since we only convert to one currency – US Dollars.
If you need to convert to multiple target currencies, then this dimension is required.

I need Multiple target currencies
to switch in excel - and see figures in chosen currency

v_SalesFact - fact table with CurrencyCode and
Sum_pos:=SUMX( v_SalesFact, [Quantity]*[LineAmount] ) - measuse

I made 2-nd table ToCurrency (same as FromCurrency)
and add condition as slicer :, 'ToCurrency'[currency_code] = "EUR"
This runs OK on SSMS and works correct, when only one ToCurrency chosen.
But when I made SAME measure s_look3 in SSDT and try to see it (s_look3) in Browse Cube
I got error :
ERROR - CALCULATION ABORTED: Calculation error in measure 'v_SalesFact'[s_look3]: A table of multiple values was supplied where a single value was expected.

DAX:

DEFINE
MEASURE 'v_SalesFact'[look1]=
if( [Sum_Pos] = 0 , 0,
-- !! here will be ERRROR !!
if( VALUES(v_SalesFact[CurrencyCode]) = VALUES( ToCurrency[currency_code]) , [Sum_pos] -- -33
,
SUMX ( v_SalesFact,
'v_SalesFact'[Sum_pos] * --v_SalesFact[SalesAmount] *
LOOKUPVALUE ( ExchangeRates[Rate]
,ExchangeRates[YearRate], YEAR( v_SalesFact[InvoiceDate] )
,ExchangeRates[MonthRate], MONTH( v_SalesFact[InvoiceDate] )
,ExchangeRates[FromCurrency], v_SalesFact[CurrencyCode]
--,ExchangeRates[ToCurrency] , "USD" -- "USD"--v_SalesFact[CurrencyCode]
,ExchangeRates[ToCurrency] , VALUES( ToCurrency[currency_code] )
)
)
)
)
-----------------------
EVALUATE
CALCULATETABLE(
ADDCOLUMNS
( 'v_SalesFact'
, "S1", 'v_SalesFact'[S1]
, "T_YTD", 'v_SalesFact'[T_YTD]
, "look1", 'v_SalesFact'[look1]

)
,'v_SalesFact'[CustomerID] = 46 || 'v_SalesFact'[CustomerID] = 27 || 'v_SalesFact'[CustomerID] = 1
, 'ToCurrency'[currency_code] = "EUR" -- "SEK" -- "EUR" -- "USD"
)
ORDER BY v_SalesFact[CustomerID] desc , v_SalesFact[InvoiceDate]



I see problem in VALUES(v_SalesFact[CurrencyCode]) =
(when I comment this - work )

but I needed to convert from EUR to EUR as 1 to 1
although there is No rates in ExchangeRates.

I know how to do it in SQL, but not in DAX.
I guess problem is in context - VALUES(v_SalesFact[CurrencyCode]) return many values
but can't guess how to do with it.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search