Tableau: Display Different Number Formats for the Same Measure

核能气质少年 提交于 2019-12-24 10:57:10

问题


I have a field in my dashboard called outcome that displays the performance results for a doctor's office for multiple measures. A majority of the outcome values are rates and should be displayed as percentages. Unfortunately, there are two outcomes, "Utilization Management: Measure 3" and "Utilization Management: Measure 5" that are NOT rates, but actually number values.

Is there a way to display the outcome field in my table so that all 'Measures' that are NOT "Utilization Management: Measure 3" or "Utilization Management: Measure 5" get displayed as percentages, while the two aforementioned measures are displayed as number values?

Please do not get hung up on the appropriateness of combining rate and number values in the same field, as I've tried to have that conversation with my customer...they are insistent on this display ability and will not let it through UAT without it. Thanks.

Same question posed and packaged workbook attached for reference here.


回答1:


I took a look at your workbook. It seems that it is not possible to dynamically format values. There is a feature idea here: https://community.tableau.com/ideas/1411 which I believe would allow you to do what you want.




回答2:


One approach is to define a string valued calculated field that makes the number format part of the calculation logic. This solution does not play well with Measure Names and Measure Values, since you can't put string valued measures on the Measure Values shelf. But you can still build the view your customer wants, with a little effort.

First create a static set based on your field [Measure] (confusing choice of field name, by the way. You have a dimension named Measure.). Call it [Percentage Measures] and check off the ones you want displayed as percentages.

Then for each of your numeric measure fields that you want treated this way, make a corresponding calculated field that looks something like:

if attr([Percentage Measures]) then
   str(round(sum([outcome]) * 100, 2)) + "%"
else
   str(round(sum([outcome]),3))
end

This approach assumes you will use your calculation on views where your dimension named [Measure] is on some (non-filter) shelf. Adjust the round() function arguments as desired



来源:https://stackoverflow.com/questions/41855267/tableau-display-different-number-formats-for-the-same-measure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!