The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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")
)
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)
User | Count |
---|---|
12 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
24 | |
14 | |
14 | |
9 | |
7 |