Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
markmess77
Resolver I
Resolver I

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.

 

1 ACCEPTED SOLUTION
markmess77
Resolver I
Resolver I

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!

View solution in original post

2 REPLIES 2
markmess77
Resolver I
Resolver I

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!

amitchandak
Super User
Super User

@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"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.