Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to visualize performance counters data stored in SQL tables using Power Bi.
It has two tables 1. CounterData 2. CounterDetails
In CounterData table datetime is stored as text format, i want to use that data as DateTime in Power Bi Desktop.
But unable to do so, How can I convert the text column into dateTime using both query mode - Import & Direct Query ?
Solved! Go to Solution.
@anikettakalkar,
I make a test using the sample table below.
In DirectQuery mode, create the following columns.
Left = LEFT(CounterData[RecordTime],FIND(" ",CounterData[RecordTime],1,0)-1)
Right = RIGHT(CounterData[RecordTime],LEN(CounterData[RecordTime])-LEN(CounterData[Left])-1)
After creating the above columns, change data type of Right column to Time. Then create the following columns.
Year = LEFT(CounterData[Left],4)
Day = RIGHT(CounterData[Left],LEN(CounterData[Left])-FIND("/",CounterData[RecordTime],6,1))
Month = MID(CounterData[Left],6,LEN(CounterData[Left])-6-LEN(CounterData[Day]))
Date = DATE(CounterData[Year],CounterData[Month],CounterData[Day])
DateTime = CounterData[Date]+CounterData[Right]
In Import mode, you can directly split the RecordTime column in Query Editor and the splited columns can be changed to Date and time format.
Then you can create a calculated column using DAX: DateTime=CounterData[RecordTime.1]+CounterData[RecordTime.2]
Regards,
Lydia
@anikettakalkar,
I make a test using the sample table below.
In DirectQuery mode, create the following columns.
Left = LEFT(CounterData[RecordTime],FIND(" ",CounterData[RecordTime],1,0)-1)
Right = RIGHT(CounterData[RecordTime],LEN(CounterData[RecordTime])-LEN(CounterData[Left])-1)
After creating the above columns, change data type of Right column to Time. Then create the following columns.
Year = LEFT(CounterData[Left],4)
Day = RIGHT(CounterData[Left],LEN(CounterData[Left])-FIND("/",CounterData[RecordTime],6,1))
Month = MID(CounterData[Left],6,LEN(CounterData[Left])-6-LEN(CounterData[Day]))
Date = DATE(CounterData[Year],CounterData[Month],CounterData[Day])
DateTime = CounterData[Date]+CounterData[Right]
In Import mode, you can directly split the RecordTime column in Query Editor and the splited columns can be changed to Date and time format.
Then you can create a calculated column using DAX: DateTime=CounterData[RecordTime.1]+CounterData[RecordTime.2]
Regards,
Lydia
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |