Power BI:如何动态更改货币

编程入门 行业动态 更新时间:2024-10-27 16:26:06
本文介绍了Power BI:如何动态更改货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们有一项要求,允许用户选择他想要在仪表板上看到的货币,例如以下示例:

We have requirement to allow user to choose which currency he wants to see in the dashboard, like below example:

默认情况下,如果用户更改为 USD ,我们需要按美元显示支出。在后台,我们已经有了表 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:

MyTable

CurrencyFormat

在 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:如何动态更改货币

本文发布于:2023-10-30 07:49:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542232.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:货币   动态   Power   BI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!