Converting hours column into day & hours and Concatenation in Power BI
In here we are going to convert the hour's column to days and hour by using variables
This variable will calculate the day and hours from the Hours column will act as input for the new column
In this example, we are calculating the employee leave days form the vacation hours
In Power BI Click on Get Data and select SQL Server the source of data
Then enter the Database engine name and click Ok
Select the tables from the database
Go to the Data tab at the left which displays the table and in the Modeling tab click on New Column
In the column added will show above the Column = here we have to write the DAX query
I am using VacationHours column for conversion
To convert the hours data into days and hours we need to replace the Column= with following query :-
Employee Leave =
var DayNo=INT([VacationHours]/24)
var HourNo=INT((Mod([VacationHours],24)))
return
DayNo&” day “&FORMAT(HourNo,”#00")&” hours”
To execute this query click on the column being created
In the below image, you can see the hours are being spilt to day and hour
Concatenation function used to join two or more string together
In this example, we are concatenating FirstName and LastName as FullName
same as above take a new column to add this query:-
Full Name = CONCATENATE(CONCATENATE(‘Person Person’[FirstName],” “),(‘Person Person’[LastName]))
If you are new to MSBI start with the following must-watch video: -