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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Frith
New Member

Different decimal places depending on conditions

Dear all,

 

I want to create a measure showing the number of employees in a bar chart. If a year or multiple months are filtered in the report I want the data labels of the bar chart to display one decimal place because then the values are means, otherwise none because then they are integers. I tried a lot of things including different formulas per condition, but it did not help. The number of decimal places set in the format section of the report seem to be dominant and overwrite any formula. So I tried to change the datatype via CONVERT: DOUBLE for the means and INTEGER otherwise. However INTEGER does not seem to be a valid argument, although it should work (https://docs.microsoft.com/de-de/dax/convert-function-dax). Further the option to change the datatype in the modeling section is greyed out and set to decimal number, although I think that would not help either, because the visual format setting seems to dominant. Is there any possible solution for this problem?

Kind regards


My code:

EmployeesBars =

SWITCH (

TRUE ()

; ISFILTERED(Di_Month[Year]) || ISFILTERED(Di_Month[Month]) && NOT HASONEVALUE(Di_Month[Month]); CONVERT(FORMAT(CALCULATE([⌀Employees]; Di_Wirkungsmonat[Status]="V"); "#.0"); DOUBLE)

; HASONEVALUE(Di_Month[MonthYearText]); CONVERT(SUM(Fa_Employment[Count])); INTEGER) --does not accept INTEGER here (error: "name could not be found")
)

1 REPLY 1
harshnathani
Community Champion
Community Champion

Hi @Frith ,

 

 

Try this measure

 

EmployeesBars =
SWITCH (
    TRUE ();
    ISFILTERED ( Di_Month[Year] )
        || ISFILTERED ( Di_Month[Month] )
            && NOT (
                HASONEVALUE ( Di_Month[Month] )
            ); CONVERT (
        FORMAT (
            CALCULATE (
                [Employees];
                Di_Wirkungsmonat[Status] = "V"
            );
            "#.0"
        );
        DOUBLE
    );
    HASONEVALUE ( Di_Month[MonthYearText] ); FORMAT (
        CONVERT (
            SUM ( Fa_Employment[Count] );
            DOUBLE
        );
        "#"
    )
)

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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