2016-04-15 62 views

回答

0

我不認爲(A)和(B)的數學與(C)一致。如果我有2英鎊,那應該接近3美元,而不是30美分。

你想要在兩個表格之間合併行通常稱爲左連接。您可以單擊合併按鈕來合併行。你想從(A)加入(B)到它。一旦你有了,你可以使用添加列進行除法和乘法來計算貨幣匯率並應用它。

完成的解決方案看起來像最終的查詢:

section Section1; 

shared LocalCurrencyTransactions = let 
    Source = Csv.Document("Country,LocalCurrencyAmounts 
    US,1 
    UK,2.13 
    JAPAN,328.08 
    INDIA,66.56 
    US,2 
    UK,0.71 
    JAPAN,109.36 
    INDIA,133.12"), 
    #"Promoted Headers" = Table.PromoteHeaders(Source), 
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Country", type text}, {"LocalCurrencyAmounts", type number}}) 
in 
    #"Changed Type"; 

shared #"FX Rates" = let 
    Source = Csv.Document("Country,LocalCurrency,USD 
    US,1,$1.00 
    UK,0.71,$1.00 
    JAPAN,109.36,$1.00 
    INDIA,66.56,$1.00"), 
    #"Promoted Headers" = Table.PromoteHeaders(Source), 
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Country", type text}, {"LocalCurrency", type number}, {"USD", Int64.Type}}) 
in 
    #"Changed Type"; 

shared CurrencyAdjustedToUSD = let 
    Source = LocalCurrencyTransactions, 
    #"Merged Queries" = Table.NestedJoin(Source,{"Country"},#"FX Rates",{"Country"},"NewColumn",JoinKind.LeftOuter), 
    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"LocalCurrency", "USD"}, {"NewColumn.LocalCurrency", "NewColumn.USD"}), 
    #"Inserted Division" = Table.AddColumn(#"Expanded NewColumn", "NewColumn.ConversionRate", each [NewColumn.USD]/[NewColumn.LocalCurrency], type number), 
    #"Inserted Multiplication" = Table.AddColumn(#"Inserted Division", "USD", each List.Product({[LocalCurrencyAmounts], [NewColumn.ConversionRate]}), type number), 
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Multiplication",{"NewColumn.LocalCurrency", "NewColumn.USD", "NewColumn.ConversionRate"}) 
in 
    #"Removed Columns"; 
相關問題