cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply

How to Convert Date given in Spanish to English

Hi There,

 

Hope you doing well .

 

I am stuck a data which have date column given in spanish and its coming in "Text" Format . When i am trying to transform this into power query its giving me an error . 
Can anyone help me out in this how can i convert this given Spanish Date value in English(Date Format)

 

Please see below screenshot for the same:

Capture_2.JPGCapture_3.JPG

 

 

 

Thanks 

1 ACCEPTED SOLUTION
sreenathv
Solution Sage
Solution Sage

In normal translation, you could use the Microsoft Translator API that can be used in Power BI.  Google it. Here you don't have to actually rely on the translation and you could do the translation in DAX itself, based on your sample data, I am giving you the following DAX code. You have to add more months to the SWITCH statement.

 

sreenathv_0-1618306331954.png

Here is the dax code.

DateEN = 
VAR DayOfTheDate = VALUE(LEFT(SpanishCalendar[Date],SEARCH(" ",SpanishCalendar[Date],1,BLANK())-1))
VAR YearOfTheDate = VALUE(RIGHT(SpanishCalendar[Date],4))
VAR MidPortion = MID(SpanishCalendar[Date],SEARCH(" ",SpanishCalendar[Date],1,BLANK())+1,LEN(SpanishCalendar[Date])-5-SEARCH(" ",SpanishCalendar[Date],1,BLANK()))
VAR MonthOfTheDate =
    SWITCH(
        TRUE(),
        MidPortion="de janeiro de",1,
        MidPortion="de fevereiro de",2,
        MidPortion="de marco de",3,
        MidPortion="de abril de",4,
        MidPortion="de novembro de",11,
        MidPortion="de dezembro de",12,
        0
    )
RETURN
DATE(YearOfTheDate,MonthOfTheDate,DayOfTheDate)

View solution in original post

3 REPLIES 3
nmasimore
Helper I
Helper I

Another solution that perhaps may work:

 

Right click column -> Change type -> Using locale

 

Search for Spanish

 

nmasimore_0-1642019736837.png

 

 

sreenathv
Solution Sage
Solution Sage

In normal translation, you could use the Microsoft Translator API that can be used in Power BI.  Google it. Here you don't have to actually rely on the translation and you could do the translation in DAX itself, based on your sample data, I am giving you the following DAX code. You have to add more months to the SWITCH statement.

 

sreenathv_0-1618306331954.png

Here is the dax code.

DateEN = 
VAR DayOfTheDate = VALUE(LEFT(SpanishCalendar[Date],SEARCH(" ",SpanishCalendar[Date],1,BLANK())-1))
VAR YearOfTheDate = VALUE(RIGHT(SpanishCalendar[Date],4))
VAR MidPortion = MID(SpanishCalendar[Date],SEARCH(" ",SpanishCalendar[Date],1,BLANK())+1,LEN(SpanishCalendar[Date])-5-SEARCH(" ",SpanishCalendar[Date],1,BLANK()))
VAR MonthOfTheDate =
    SWITCH(
        TRUE(),
        MidPortion="de janeiro de",1,
        MidPortion="de fevereiro de",2,
        MidPortion="de marco de",3,
        MidPortion="de abril de",4,
        MidPortion="de novembro de",11,
        MidPortion="de dezembro de",12,
        0
    )
RETURN
DATE(YearOfTheDate,MonthOfTheDate,DayOfTheDate)

Thank you @sreenathv  .

 

Really appreicate your help.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors