March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
In summary: My measure produces either text or an integer. The integer has decimal places.
I want the number to display 0 decimal places. If I change the number to text, I cannot sort it correctly.
I cannot change the Data Type of the measure to a number, as the measure can contain a text string.
Background:
Based on my data, I have created a for a report that normally would look like:
Year Number
_______________
2014 21 2015 9 2016 2 2017 15
(please excuse the formatting)
I want to hide the exact number of students if there are fewer than 10 of them, but still include them in the data, rather than simply having them disappear.
I would like it to display:
Year Number
_______________ 2014 21 2015 <10 2016 <10 2017 15
I came up with a partial solution last night:
Number of offers = IF([Number]>9, [Number],"<10")
Unfortunately this presents a new problem: the number is formatted to include decimal places:
Year Number
________________ 2014 21.00 2015 <10 2016 <10 2017 15.00
As I will never have half a student, this is not acceptable.
If I try to use
Number of offers = IF([Number] >9, FORMAT([Number],""),"<10")
, the table appears to be correct, but because the numbers are formatted as text, they cannot be sorted accurately. For example, they appear as:
Animal Number ________________ Fly 1001 Dog 109 Cat 1547 Rat 191
I have tried a few methods including VALUE, FIXED and various FORMAT, but I can't get what I want!
In summary: I want to format the numbers as a number, but without two decimal places.
I cannot change the Data Type to number, as the measure can contain a text string.
Any help appeciated.
Hi,
I think that you can use the formula that you came up with for the measure (it will be Text). To make it sort as you want you can set the Sort by Column to be the original [Number] Column.
To do this select your measure in the fields list and then on the Modeling Tab select Sort by Column and select the Number Field.
Sadly this won't work, as I am working with a COUNT and therefore can't sort on the column itself.
Please forgive me, as I simplified a little on my first post:
-- My starting code: Number of offers = IF(COUNT([NumberOfStudents]) >9, COUNT[NumberOfStudents],"<10") -- My first proposed solution: Number of offers = IF(COUNT([NumberOfStudents]) >9, FORMAT(COUNT[NumberOfStudents],""),"<10")
After further testing, it appears that:
Therefore I need either:
One question I have is why you're using "" in FORMAT fn, instead of 0. I'm not very much into FORMAT fn, but as far as I knew, the latter is the formatting for a whole number w/o decimals. Maybe then you will have the values to be sorted numerically, not alphabetically
Using 0 in the FORMAT still results in the number being formatted as text, ruining the sort
I've also tried formatting the <10 as a number, adding the '<' using the FORMAT fn. No luck.
Using VALUE presents it as a number; but with the two decimal places that I want to lose.
Thanks for your suggestions so far! I think that this is a bug/missing feature in DAX, or a problem with the way that Power BI visualisations deal with numbers: not allowing the formatting of numbers when they can appear in a field appear alongside text.
Still, I feel that there must be some way around it.
Hi @TM_Visual,
Please check which kind of format did you set for the Number column, make sure it's Whole Number instead of Decimal number. Also please update the Power BI desktop to the latest version 2.47.4766.801 64-bit (June 2017).
If issue persists, please share .pbix file with us if possible.
Best Regards,
Qiuyun Yu
Hi, my Desktop is up to date.
Because I have a measure that includes text, I cannot list it as a number.
An example is pictured.
Table 1 is a simple count of the data.
Table 2 is a measure that replaces low values with text. There are unwelcome two decimal places on the numbers. The Measure is
Number of animals = IF(COUNT(Table01[Animals])>10,COUNT(Table01[Animals]),"fewer than 10")
Table 3 is a measure that formats the numbers. Now, the table will not sort correctyy: It places 1084 as lower than 90. That measure is:
Number of animals as text = IF(COUNT(Table01[Animals])>10,FORMAT(COUNT(Table01[Animals]),""),"fewer than 10")
I used a very simple, one-column table with a list of animals to create this example. Please advise me jhow I can share it with you if desired.
Hi @TM_Visual,
I have reported this issue internally, CRI 40800356. Will update here once I get information.
Best Regards,
Qiuyun Yu
Hi @TM_Visual,
I got information below internally:
"Since the DAX expression returns either a number or a text, the UI currently doesn't give users an option to format the numbers for such measures.
We currently do not support variant measure formatting. Log this request on the Power BI Ideas site."
For your requirement, you can post a request in Ideas forum.
Best Regards,
Qiuyun Yu
As noted in my community post here , there is an issue where the 'table' and 'table preview' visualisations (and possibly others) will automatically display all numbers to two decimal places if there is a mixture of numbers and text displayed in that column.
This applies even when:
* There are no decimal places worth noting: e.g. all integers are 500.00 / 34.00 / 1.00
* The numbers are formatted as numbers using the FORMAT function
* The 'text' part is a number that has been FORMAT'ed as text or as a number (e.g. FORMAT fn "General number")
If all of the numbers are formatted using the FORMAT function or others, the decimal points disappear. However, the values then left-align (by default) as text, and will not sort as proper numbers: e.g. they will order 1001, 109, 1547, 191, 2000.
I was using this table with a COUNT measure, so I cannot use the 'Sort by column' to sort, and I want the sort order to be easily changed by users.
My measure produces text OR a number. I want to remove decimals from the number,but remain sortable.
As an example, the following produce a result with the numbers with two unnecessary decimal places, eg. 524.00. These do sort correctly.
'Basic formula: Number of applicants =IF(COUNT('ApplicationsQuery1'[Applicants])>10,COUNT('ApplicationsQuery1'[Applicants]),"<10") 'Specify as VALUE: Number of applicants = IF(COUNT('ApplicationsQuery1'[Applicants])>10,VALUE(COUNT('ApplicationsQuery1'[Applicants])),"<10") 'FORMAT fn "Fixed" : Number of applicants = IF(COUNT('ApplicationsQuery1'[Applicants])>10,FORMAT(COUNT('ApplicationsQuery1'[Applicants]),"Fixed"),"<10") FORMAT fn "standard" : Number of applicants = IF(COUNT('ApplicationsQuery1'[Applicants])>10,FORMAT(COUNT('ApplicationsQuery1'[Applicants]),"standard"),"<10")
Number of applicants = IF(
COUNT('ApplicationsQuery1'[Applicants])>10,COUNT('ApplicationsQuery1'[Applicants]),FORMAT(10,"\<#,##"))
The following produce a result with whole numbers, but they only sort as text:
'FORMAT fn "" : Number of applicants = IF(COUNT('ApplicationsQuery1'[Applicants])>10,FORMAT(COUNT('ApplicationsQuery1'[Applicants]),""),"<10") 'FORMAT "0" : Number of applicants = IF(COUNT('ApplicationsQuery1'[Applicants])>10,FORMAT(COUNT('ApplicationsQuery1'[Applicants]),0),"<10")
In another issue I will raise a suggestion that we can automatically choose to have values below a specified amount display as '<10' or '>9000', but that's a separate issue.
To offer an example, please see the image in the Community post here: http://community.powerbi.com/t5/Desktop/My-measure-produces-text-OR-a-number-I-want-to-remove-decima...
Table 1 is a simple count of the data.
Table 2 is a measure that replaces low values with text. There are unwelcome two decimal places on the numbers. The Measure is
Number of animals = IF(COUNT(Table01[Animals])>10,COUNT(Table01[Animals]),"fewer than 10")
Table 3 is a measure that formats the numbers. Now, the table will not sort correctyy: It places 1084 as lower than 90. That measure is:
Number of animals as text = IF(COUNT(Table01[Animals])>10,FORMAT(COUNT(Table01[Animals]),""),"fewer than 10")
I used a very simple, one-column table with a list of animals to create this example.
I think you can use the ROUND function in your measure instead of FORMAT here.
Hi @foyiq, thanks for the try, but it still shows the decimal (tried with any number specified value in the second part of the ROUND formula)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |