Decimal with digits precision on scorecard - powerbi

I am trying to display a decimal on the scorecard. By default it goes for a whole number but i want 1 digit precision. E.g. instead of 99 display 92.1.

Select the source column, go to the Modeling -> Formatting
And set:
Data Type: Decimal Number
Format: Decimal Number
And in the dropdown below select the number of digits precision required.

Related

do a format for only one row?

I have this measure in DAX:
SWITCH ( TRUE () ,
MIN ( 'Dynam'[ID] ) = 5 , DIVIDE ( [Gross] , [Revenue] ) * 100,
MIN ( 'Dynam'[ID] ) = 8 , [Hours]
)
I would like the first one to have one decimal, but not the second one.
Can I do a formatting for one row only?
As of now, I have it like this for the entire measure:
Here are a few options:
Like Jeroen said, you can use FORMAT in your measure but it will be text. If you can't have the measure as text is some places, just have a text measure and a number measure.
Use two measures, one for hours and one for dollars. You can't really chart or SUM things well when sometimes it's hours and sometimes it's dollars, so split them out.
You could always drop the decimals on the dollars and use whole number for both.
If your data for both is always positive, you can play tricks with the positive and negative formats in Power BI (and probably SSAS?) using a custom format string such as 0.00;0;0. In a custom format string, the first format is the positive number, the second is negative, and the last is zero. The trick is to use the positive format for dollars and the negative format for hours. Here, positive numbers are shown with decimals (0.00), negative numbers are shown as whole numbers without a minus sign so that they look like positive numbers (0):

Regex to accept only numeric input with whole and half decimal point

I have used the below regex but it accept all values after decimal point. I want only whole numbers ( eg: 12) and half decimal point (eg 12.5)
Regex regex = new Regex("[^0-9.]+");
I want the below behavior.
For example
Valid numbers : 12, 12.5
Invalid numbers 12.1, 12.8
Try using this pattern:
\d+(?:\.5)?
This would match whole numbers, as well as numbers which half just a decimal component of 0.5. If you also want to allow for 0.0 decimal endings, then use:
\d+(?:\.[05])?
For your actual code, you may use:
Regex regex = new Regex("#\d+(?:\.5)?");

Output division result including digits after decimal - Qt

I am sorry if it's already answered in here, but I couldn't find the exact solution I am looking for.
I am trying to output the result of a division of two variable which is continuously changing. The result may vary from 0.00 to 100.12314235234523 (not exactly this specific, I just wanted to give you an idea). I want to print the result only 2 digits after the decimal point, if there is nothing after decimal, it should print 2 zeroes after decimal.
For example:
10 / 5 = 2.00
23 / 6 = 3.83
I don't need to round up the result for example, if the output is: 73.4869999, I don't need it to be 73.49, 73.48 is fine with me.
What I have written so far is:
packet_loss[2]->setText(QString("%1%2%3").arg(((data.packet_loss_tx) * 100) / data.packets_tx).
arg(locale.decimalPoint()).
arg((((data.packet_loss_tx) * 100) % data.packets_tx), 2, 10, QChar('0')));
But this prints all the values after the decimal point. I can divide this part arg((((data.packet_loss_tx) * 100) % data.packets_tx) with 10, 100 or 1000 to reduce the number of decimals after the decimal point but this is a variable which changes every seconds. So if the output is 3 digits after decimal and I divide it by 10, I will get proper output, but the next value may be 5 digits after decimal and division by 10 will give me 4 digits after decimal. I want the final output to show only 2 digits after decimal.
You could try to use QString::number() function with specific formatting options (two digits precision). For example:
auto s = QString::number(100.12914235234523, 'f', 2); // Gives "100.13"
Besides, if you use floating point numbers, it's better to multiply them with floating point numbers too. I.e. you need to perform your calculations using 100.0 instead of integer value 100.

Regexp for digit with decimal with maximum value

I have a regexp to check for a decimal with 2 numbers, but I want to check both the integer and the decimal part for their length.
/^\s*-?[1-9]\d*(\.\d{1,2})?\s*$/;
The above code is decimal with length 2 (ex: 12.23) but I want 10 integer value and 2 decimal value (10,2) like,
1234567890.12
Use /^(?![.])\d{0,10}(\.\d{1,2})?$/
It allows 1.23, 1.2 0.2
Invalid values ., 1.
Depending on what you exactly want, you can use:
/^\s*-?(\d{1,10}(\.\d{1,2})?)\s*$/
for input like: 12.23, 3.4, 1234567890.34, 4, 456, etc., or:
/^\s*-?(\d{10}(\.\d{1,2})?)\s*$/
for: 9087654321, 1234567890.1, 1234567890.23 (10 digits, and optional point and one or two digits), or:
/^\s*-?(\d{10}\.\d{2})\s*$/
for exactly 10 digits fallowed by point and 2 digits, like: 9087654321.12, etc. Its all depends on what kind of numbers you want to filter.

Regular expression for counting decimals

I need to validate a Textbox input which accepts decimal values. I require to count the number of digits entered after dot in the decimal number and restrict if the precision is more than 5.
Ex
Valid values
1.2
15.256
25.25486
Invalid
455.256485
^\d*(?:\.\d{1,5})?$
This should validate decimals with 5 after ..
^\d*(?:\.\d{1,5})$
Use this if it is striclty for decimals and not integers.