Forum Discussion
Help with dax and unichar
Is it possible to show the result with unichar in a single measurement?
I tried this:
but the result was this:
however I need the value in percentage: -9,42% and unichar code
Glad to hear you've solved the main issue.
The latest problem looks to be due to blank values of x falling into the 2nd branch of IF.
I suggest adjusting your measure to return a blank result when x is blank.
Here is how you could write it:
Variação Média CNE180 = VAR vVariacao = [m_CNE180] - [6M CNE180] VAR x = DIVIDE ( vVariacao, [6M CNE180], 0 ) RETURN IF ( NOT ISBLANK ( x ), IF ( x < 0, FORMAT ( x, "0.00%" ) & UNICHAR ( 9989 ), FORMAT ( x, "0.00%" ) & UNICHAR ( 10060 ) ) )An alternative you may want to look at is to leave your measure as this:
Variação Média CNE180 = VAR vVariacao = [m_CNE180] - [6M CNE180] VAR x = DIVIDE ( vVariacao, [6M CNE180], 0 ) RETURN xbut give it this custom format string:
0.00%\❌;0.00%\✅;0.00%\❌See here:
Does one of the above methods work for you?
3 Replies
- OwenAuger
Super User
Hi yforti
You can use the FORMAT function to return a value with a specific number format as text.
In this case, you could change the final expression to
FORMAT ( x, "0.00%" ) & UNICHAR ( 10004 )I would also suggest considering leaving the measure as a number, but using a format string to control the formatting (possibly a dynamic format string).
For example, a simple format string for negative values could be:
"0.00%\✔"Here's a good article on this subject:
https://www.sqlbi.com/articles/improving-data-labels-with-format-strings/
Regards
- yforti
Helper II
Thnks man! It worked!
The only problem is:
before with the measurement as shown in the photo, it only brought the relevant values->, now with the change in measurement, it is bringing values to all lines->
Can u help me?
- OwenAuger
Super User
Glad to hear you've solved the main issue.
The latest problem looks to be due to blank values of x falling into the 2nd branch of IF.
I suggest adjusting your measure to return a blank result when x is blank.
Here is how you could write it:
Variação Média CNE180 = VAR vVariacao = [m_CNE180] - [6M CNE180] VAR x = DIVIDE ( vVariacao, [6M CNE180], 0 ) RETURN IF ( NOT ISBLANK ( x ), IF ( x < 0, FORMAT ( x, "0.00%" ) & UNICHAR ( 9989 ), FORMAT ( x, "0.00%" ) & UNICHAR ( 10060 ) ) )An alternative you may want to look at is to leave your measure as this:
Variação Média CNE180 = VAR vVariacao = [m_CNE180] - [6M CNE180] VAR x = DIVIDE ( vVariacao, [6M CNE180], 0 ) RETURN xbut give it this custom format string:
0.00%\❌;0.00%\✅;0.00%\❌See here:
Does one of the above methods work for you?