do a format for only one row? - powerbi

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):

Related

Extracting currency value in Google Sheets with regex

I am trying to extract the tip value from columns in Google Sheets. What would be the proper regex argument to use to do this? Some columns do not have the tip value, and in this case i would like it to return "0".
Tip - 20% x $134.00Damage Waiver: 5% x $40.20Coupon: Thanks for considering us!! x -$10.00Tax: 7.25% of $700.20 x $50.76
If the input string (let's say at A1) has the word "Tip", and the first dollar symbol after that initiates the amount of interest, then do:
=IFNA(VALUE(REGEXEXTRACT(A1, "\bTip\b[^$]*\$([\d.]+)")), 0)
This expression will produce a number type, so the dollar is not included.
Apply the desired number formatting to the cell where you place this formula to show a currency symbol, and the required number of decimals.

Remove Zeros Before Decimal- PowerBI

Numbers under 1 are currently being represented with a leading zero before the decimal point (example: 0.50). Because I'm working with baseball statistics (which almost never have the zero before the decimal) I would like to remove that. I want to keep the number before the decimal if its greater than 1 though. How would I do that?
For instance if I'm working with this measure. Is there something I can add to that?
AVG = SUM(Batter[H])/sum(Batter[AB])
Thanks. I appreciate the help.
Here is some sample data
Name AB H
Gleyber Torres 546 152
Brett Gardner 491 123
Aaron Judge 378 103
Adam Ottavino 0 0
Aroldis Chapman 0 0
The NAN error is occurring because you are dividing by 0. You should add an IF condition to avoid that:
AVG = IF(sum(Batter[AB])=0,BLANK(),SUM(Batter[H])/sum(Batter[AB]))
To tackle the formatting issue you can use the FORMAT function as mentioned by Andrey:
AVG = IF(sum(Batter[AB])=0,BLANK(),FORMAT(SUM(Batter[H])/sum(Batter[AB]),"###.0#"))
Hope this helps.
Unfortunately, it isn't directly possible. However, in the last step (the visualization of the data), you can convert the decimal number to text and format it as you want. For example, your measure could be like this:
AVG = FORMAT(SUM(Batter[H])/SUM(Batter[AB]), "#,###.00")
This will give you 2 decimal places (0 means that there will be a digit displayed at this position), but the digits before the decimal are optional (# means it will show a digit, but will omit the leading zeros) or here are some examples:

How can I convert an integer like "170526" into its equivalent date (in this case 05/26/17)?

In my spreadsheet, I've got a bunch of dates formatted weird like:
170526
180921
181002
181002
181021
I'd like to use a formula and convert those over to:
05/26/17
09/21/18
etc.
where the first two digits are the year, middle two is the month, and the last two are the day.
=ARRAYFORMULA(IF(LEN(A1:A), MID(A1:A, 3, 2)&"/"&RIGHT(A1:A, 2)&"/"&LEFT(A1:A, 2), ))
=ARRAYFORMULA(IF(LEN(A1:A),
TEXT(("20"&REGEXREPLACE(""&A1:A, "\d{2}(\B)", "$0-")), "mm/dd/yy"), ))
=("20"&REGEXREPLACE(""&A1,"\d{2}(\B)","$0-"))*1
REGEX to REPLACE border of every two digits with -
"20"& to add year
*1 to convert string to date value.
Format>Number>Date

Decimal with digits precision on scorecard

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.

How to keep leading zero and add comma in openoffice calc formula?

I have 6 fields in a row in open office, the 1st is a word, the 2nd, 3rd, and 4th are a number with a leading zero, the 5th and 6th are regular numbers. How do I join them all together with a comma between them so that the leading zero stays?
Based on your comment about your numbers having a leading 0 in virtue of a custom number format, you need to incorporate TEXT() functions into your formula to retain (i.e., add) your leading 0s.
=CONCATENATE(A1,",",TEXT(B1,"0#####"),",",TEXT(C1,"0#####"),",",TEXT(D1,"0#####"),",",E1,",",F1)
Just be sure to include as many #'s as the max length of a number in that field.
Please try:
=A1&",0"&B1&",0"&C1&",0"&D1&","&E1&","&F1