Forum Discussion

harshagraj's avatar
harshagraj
Icon for Post Partisan rankPost Partisan
2 years ago

Day,Hour,Minutes and additional parameters

Hello all i have a below data.

ItemsValueDateTime
Single-Top0.03400693/7/2024 2:28
Single-Top0.03400693/7/2024 4:10
Single-Top0.03400693/7/2024 8:07
Double Top0.53/7/2024 9:16
Double Top0.53/7/2024 9:22
Double Top0.53/7/2024 9:26
PTC103/7/2024 9:40
PTC103/7/2024 9:40
PTC103/7/2024 9:42
PTC103/7/2024 9:57
PTC103/7/2024 10:06
PTC103/7/2024 10:39
PTC103/7/2024 10:47
SDC0.73/7/2024 10:51
SDC0.73/7/2024 11:22
SDC0.73/7/2024 11:31
SDC0.73/7/2024 11:31
SDC0.73/7/2024 12:06
SDC0.73/7/2024 12:27

 

i have plotted a scatter plot on this. Now based on the datetime field i have to create these below parameters like Days, Hours,Minutes etc or like last N miutes, last n hours etc. Basically user needs a button or a dropdown.
amitchandak  please help if we can do this using a power query. 

3 Replies

  • Dangar332's avatar
    Dangar332
    Icon for Resident Rockstar rankResident Rockstar

    hi, harshagraj 

    in power query make a three  custome columns and use below code
    for day

    Date.Day([date])

     

    for hour
    Time.Hour([date])

    for minute

    Time.Minute([date])

     

     

    or add below code in your advance editor

     

     #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.Day([date])),
        #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Time.Hour([date])),
        #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each Time.Minute([date]))

     

     

     

    • harshagraj's avatar
      harshagraj
      Icon for Post Partisan rankPost Partisan

      Hi Dangar332 thanks a lot for your response but i need a parameter or a slicer to be used to represent that datetime in day,hour,minute etc like this. 

       

      • Dangar332's avatar
        Dangar332
        Icon for Resident Rockstar rankResident Rockstar

        hi, harshagraj 

         

        in power bi desktop go to modelling tab > new parameter >select field> drag and drop column of day,minute,hour(which we make in power query) > and select create

         

        here column name is different from you 

         

        field parameter interface look like below

         

         

        refer ARTICLE for more about Field parameter

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.