Forum Discussion

AliRashed2024's avatar
AliRashed2024
New Member
2 years ago
Solved

Creating Timestamp and Visualization

Hi Everyone,
I an new on working on Power BI and I seek you help on urgent assignment. 


I have a project in Power BI, to visual Activity based on Time. There are certian Acitivties are not generated from the system which I must also inculde. 

the question is: I have an activities called "Customer Services" and the time give per day is 2 hours. since such activities will not occur in exact time during the day I would like to divide the 2 / 8 "Working Hours" so when I visualize it it show from 9 am to 5 pm.



The current Table I have as the following Columns:
Date
Activity

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi AliRashed2024 ,

    I have assumed some data, 'Table' surface system-generated data and 'Table2' represents activities that do not exist in the system.

     

    Please follow these steps:

    1.Appending Two Tables Together Using Power Query

    2.Use the following DAX expression to create a table named 'Time'

    Time = ADDCOLUMNS(GENERATESERIES(TIME(9,0,0),TIME(17,0,0),TIME(1,0,0)),"Column",HOUR([Value])*100+MINUTE([Value])*10+MINUTE([Value]))

    2.Use the following DAX expression to create columns in 'Table'

    Column1 = IF(ISBLANK([StartTime]),900,HOUR([StartTime]) *100 + MINUTE([StartTime])*10 + SECOND([StartTime]))
    Column2 = IF(ISBLANK([EndTime]),1700,HOUR([EndTime]) *100 + MINUTE([EndTime])*10 + SECOND([EndTime]))

    3.Use the following DAX expression to create a measure

    Measure = 
    VAR _a = SELECTEDVALUE('Time'[Column])
    VAR _b = CONCATENATEX(FILTER('Table','Table'[StartTime] <= _a && 'Table'[Column2] >= _a ) ,'Table'[Activity]," "&",")
    RETURN _b

    4.Final output

     

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AliRashed2024 ,

    I have assumed some data, 'Table' surface system-generated data and 'Table2' represents activities that do not exist in the system.

     

    Please follow these steps:

    1.Appending Two Tables Together Using Power Query

    2.Use the following DAX expression to create a table named 'Time'

    Time = ADDCOLUMNS(GENERATESERIES(TIME(9,0,0),TIME(17,0,0),TIME(1,0,0)),"Column",HOUR([Value])*100+MINUTE([Value])*10+MINUTE([Value]))

    2.Use the following DAX expression to create columns in 'Table'

    Column1 = IF(ISBLANK([StartTime]),900,HOUR([StartTime]) *100 + MINUTE([StartTime])*10 + SECOND([StartTime]))
    Column2 = IF(ISBLANK([EndTime]),1700,HOUR([EndTime]) *100 + MINUTE([EndTime])*10 + SECOND([EndTime]))

    3.Use the following DAX expression to create a measure

    Measure = 
    VAR _a = SELECTEDVALUE('Time'[Column])
    VAR _b = CONCATENATEX(FILTER('Table','Table'[StartTime] <= _a && 'Table'[Column2] >= _a ) ,'Table'[Activity]," "&",")
    RETURN _b

    4.Final output