Forum Discussion

markmess77's avatar
markmess77
Icon for Resolver I rankResolver I
6 years ago
Solved

How to debug my measure output?

I have a fairly simple measure as follows, that outputs a number of two decimal places.

Output =
[Measure 1] - CALCULATE ( [Measure 1], DATEADD ( 'Calendar'[Date], -1, YEAR ) )

However, when I use this same thing in a bit of a more complicated context, it only returns an integer. No decimal places are shown. In my case, I am using it with the switch function:

Output = 
SWITCH (
    TRUE (),
    VALUES ( 'TI Filter'[Calculation Type] ) = "Last Year",
                [Measure 1]
            - CALCULATE ( [Policy Returned %], DATEADD ( 'Calendar'[Date], -1, YEAR ) ),
    VALUES ( 'TI Filter'[Calculation Type] ) = "Last Quarter",
        [Measure 1]
            - CALCULATE ( [Measure 1], DATEADD ( 'Calendar'[Date], -1, QUARTER ) ),
    VALUES ( 'TI Filter'[Calculation Type] ) = "Last Month",
        [Measure 1]
            - CALCULATE ( [Measure 1], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
)

Is there a reason why it does not return decimals when it is used with the switch function?

I also have another measure identical to the one above that returns an output with two decimals. Everything is exactly the same, but a `Measure 2` takes place of `Measure 1`. Measure 1 and Measure 2 are also calculated in the exact same manner. I just don't get why one returns decimals and the other does not.

I also tried using the FORMAT function, but my bar chart errors out when it is used.

 

  • Still not really sure what was happening, but I fixed it. I just played with the visual and measure.. deleting them both and putting them back in and now it's working fine. Measure is completely the same, I literally just copied the same expression into another measure. Weird but it's solved now!

2 Replies

  • markmess77 , Not very clear.

     

    When you are using these measures in Switch You can multiply them with 1.0 , Also make sure the data type of output is decimal

     

    also , you might have to use max ( 'TI Filter'[Calculation Type] ) = "Last Year"

    in place of values( 'TI Filter'[Calculation Type] ) = "Last Year"

  • Still not really sure what was happening, but I fixed it. I just played with the visual and measure.. deleting them both and putting them back in and now it's working fine. Measure is completely the same, I literally just copied the same expression into another measure. Weird but it's solved now!