Forum Discussion

UIUser's avatar
UIUser
Frequent Visitor
1 year ago
Solved

Date formatting in wrong way when converted to text

Hi,    I have a date that I need to connect with a text piece. Now when I combine my selected date with the text the date comes out in a wrong format (US date format, MM/DD/YYYY, 1/31/2025) allthou...
  • DataNinja777's avatar
    1 year ago

    Hi UIUser ,

     

    The issue occurs because when you concatenate a date with text in DAX, Power BI implicitly converts the date to a string using the default US format (MM/DD/YYYY), ignoring your regional settings. This happens even if your system or file is configured for German formatting. To fix this, you need to explicitly format the date before concatenation. Use the FORMAT function to define the correct European date structure. For example, instead of relying on SELECTEDVALUE to output a date directly, wrap it like this:

    header_ertragleer_previous_month = 
    "Ertrag leer per " & FORMAT(SELECTEDVALUE('bm dim_month'[month_end]), "DD.MM.YYYY")
    

    This ensures the date appears as 31.01.2025 regardless of Power BI’s internal preferences. If you want to reinforce the language tag just in case, use the following format string:

    header_ertragleer_previous_month = 
    "Ertrag leer per " & FORMAT(SELECTEDVALUE('bm dim_month'[month_end]), "[$-de-DE]dd.mm.yyyy")
    

    This forces the German locale format and avoids any surprises when the report is opened elsewhere.

     

    Best regards,