๐ง๐ต๐ฒ ๐ป๐ฒ๐ ๐๐๐ป๐ฎ๐บ๐ถ๐ฐ ๐๐ผ๐ฟ๐บ๐ฎ๐ ๐ฆ๐๐ฟ๐ถ๐ป๐ด๐ ๐ณ๐ผ๐ฟ ๐บ๐ฒ๐ฎ๐๐๐ฟ๐ฒ๐ ๐ณ๐ฒ๐ฎ๐๐๐ฟ๐ฒ ๐ณ๐ฟ๐ผ๐บ ๐๐ต๐ฒ #PowerBI ๐๐ฝ๐ฟ๐ถ๐น ๐ฎ๐ฌ๐ฎ๐ฏ ๐๐ฝ๐ฑ๐ฎ๐๐ฒ.
currency conversion to โฌ, $ or ยฃ depending on the country && time conversion to days/hours/minutes/seconds according to the duration
This feature improves the overall readability of the data visualization by giving us the flexibility to adjust the format string to a variety of contexts within a report.
With this great feature (previously only available in Calculation Groups using Tabular Editor), we can now create the desired format string that dynamically fits our values using a DAX expression and use it directly in Power BI Desktop !
This gives us the flexibility to adjust the format string to a variety of contexts in our reports.
1) Currency conversion to โฌ, $ or ยฃ depending on the country
๐In this short demo, I show you a currency conversion scenario and how to dynamically switch from one currency value format to another, like โฌ, $ or ยฃ, depending on the country.
To add a dynamic format string to a measure, we need to click the measure in the Data pane, then in the Measure tools ribbon Format dropdown choose โDynamicโ=>then in the "Format" dropdown we can enter the DAX expression defining our dynamic format string.
๐Here is the DAX code string used:
SWITCH(SELECTEDVALUE(dimLocation[country]),
"Canada", "$",
"US", "$",
"UK", "ยฃ",
"Germany","โฌ",
"France", "โฌ",
//Total
" ") & " #,0.00"
2) Time conversion to days/hours/minutes/seconds according to the duration
๐Here is another example of dynamic strings formatting in days/hours/minutes/seconds according to the current duration.
๐Here is the DAX code string used:
var Seconds= [Duration formatted]
var Minutes=int( Seconds/60)
var Remaining_Seconds=MOD(Seconds, 60)
var Hours=INT(Minutes/60)
var Remaining_Minutes=MOD(Minutes,60)
var Days=INT(Hours/24)
var Remaining_Hours=MOD(Hours,24)
return """"&
switch( TRUE(),
Seconds <60, Seconds & " Seconds",
Seconds <3600, Remaining_Minutes & " Minutes - "& Remaining_Seconds & " Seconds",
Seconds <86400, Remaining_Hours &" Hours - "& Remaining_Minutes & " Minutes - "& Remaining_Seconds & " Seconds",
Days & " Days - "& Remaining_Hours &" Hours - "& Remaining_Minutes & " Minutes - "& Remaining_Seconds & " Seconds")