我们有一项要求,允许用户选择他想要在仪表板上看到的货币,例如以下示例:
We have requirement to allow user to choose which currency he wants to see in the dashboard, like below example:
默认情况下,如果用户更改为 USD $,则为 GBP c $ c>,我们需要按美元显示支出。在后台,我们已经有了表 InvoiceDetail ,该表包含预先进行货币换算的列:
By default, it's GBP, if user changes to USD, we need to show the spend by USD. Under the hood we already have table InvoiceDetail which contains columns doing currency conversion beforehand:
SpendInGBP SpendInUSD SpendInEUR我不确定如何处理当用户使用ChicletSlicer选择不同的货币映射到不同的列。
I am not sure how I can map when user chooses different currency using ChicletSlicer to different Columns.
推荐答案如果您有一个包含所有可用格式的表,可以
If you have a table containing all formats available to apply this can be achieved.
我已经创建了以下表格:
I've created these tables as example:
MyTableCurrencyFormat
在 MyTable 表中,我创建了两个度量,分别称为 Format 和 Total Sales 。
In the MyTable table I've created two measures called Format and Total Sales.
Format = LASTNONBLANK ( CurrencyFormat[Format], 1 )总销售额=总销售额= FORMAT(SUM(MyTable [Sales]),[Format])
注意总销售额度量使用 [Format] 测量以从切片器中获取选定的格式。
Note Total Sales measures uses the [Format] measure to get the selected format from the slicer.
添加ChicletSlicer并从中设置 FormatName 列 Category 窗格中的 CurrencyFormat 表,您应该得到预期的结果。
Adding the ChicletSlicer and setting FormatName column from CurrencyFormat table in Category pane, you should get the expected result.
还要注意,我使用的格式可能与您需要的格式有所不同,因此您必须在格式字符串中添加一些更改,快速阅读有关此文档的文档。
Also note the formats I've used can vary from what you need, so you have to add some changes to the format strings, do a quick read of the documentation about it.
Format Region $#,##0;($#,##0) SpendInUSD £#,##0;(£#,##0) SpendInGBP €#,##0;(€#,##0) SpendInEUR更新:OP希望基于切片器获取右列的总和。
UPDATE: OP wants to get the sum of the right column based on the slicer.
幸运的是,您的表中有每种货币的列,正如您在我的建议中将切片器值映射到您的量度时所发现的,这是最终表达式:
Fortunately your table has a column for every currency, as you found with my proposal to map the slicer value to your measure, this is the final expression:
Spend = IF ( LASTNONBLANK ( 'Currency'[Code], 1 ) = "GBP", SUM ( Invoice[SpendGBP] ), IF ( LASTNONBLANK ( 'Currency'[Code], 1 ) = "USD", SUM ( Invoice[SpendUSD] ), SUM ( Invoice[SpendEUR] ) ) )让我知道您是否需要进一步的帮助。
Let me know if you need further help.
更多推荐
Power BI:如何动态更改货币
发布评论