Dennix
Dennix

Reputation: 115

PowerBI: Measure with multiple datatype formats in visual

I want to have a dynamic measure (multiple measures based on a selection) as values of a line chart. The dynamic measure is selected over a slicer (from a separate table that only has one column [Dynamic Measure] with this two values). Then the measure [Dynamic Value] is calculated with DAX:

Dynamic Value= IF(
    SELECTEDVALUE(Table[Dynamic Measure]) = "Measure1",
    'Report Measures'[Measure1],
    CONVERT('Report Measures'[Measure2], INTEGER)
)

This works mostly fine. My only problem is that the two measures have different datatypes, DOUBLE and INTEGER. I would like the line to reflect this, so that when you hover over the chart the numbers get formatted based on the selected measure (e.g. 11.3 for Measure1 and 134 for Measure2). So far I can only apply one formatting, the one I specify for [Dynamic Value] (e.g. 11.3 for Measure1 and 134.0 for Measure2). The formats I specify for Measure1 and Measure2 are overruled and using CONVERT within [Dynamic Value] also did not yield any results.

Is this possible to achieve with PowerBI?

Upvotes: 0

Views: 662

Answers (1)

Dennix
Dennix

Reputation: 115

I assumed this would be quite tricky to achieve (if possible at all) as this post: https://community.powerbi.com/t5/Desktop/Measure-with-multiple-format-types/m-p/317648 had the problem unresolved. Yet I think I just found a pretty simple solution. I had to set the Format of [Dynamic Value] to General and get the number of decimal places over the ROUND function:

Dynamic Value = IF(
    SELECTEDVALUE(Table[Dynamic Measure]) = "Measure1",
    ROUND('Report Measures'[Measure1], 1),
    'Report Measures'[Measure2]
)

Upvotes: 0

Related Questions