Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
XaviOV
Helper V
Helper V

Crear tabla con fecha y hora

Hola

Necesito crear una tabla de fechas con todas las horas que tiene un día y que aparecen cada hora, es decir, de 00.00 a 23:00:00, una cita con cada hora.

La tabla debe comenzar a partir de 2016.

Salud

Xavi

1 ACCEPTED SOLUTION

Hola @XaviOV ,

Reemplazar 2020 por año (hoy())

Table 2 = 
ADDCOLUMNS (
    CROSSJOIN (
        CALENDAR ( DATE ( 2016, 1, 1 ), DATE ( YEAR(TODAY()), 12, 31 ) ),
       'Table (2)'  
    ),
    "DateTime", [Date]+[Time]
)

Saludos
Liang
Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

Hola @XaviOV ,

También puede intentar introducir una tabla de tiempo de 0:00:00 a 23:00:00 y, a continuación, utilizar la función Crossjoin.

Table 2 = 
ADDCOLUMNS (
    CROSSJOIN (
        CALENDAR ( DATE ( 2016, 1, 1 ), DATE ( 2020, 12, 31 ) ),
       'Table (2)'  
    ),
    "DateTime", [Date]+[Time]
)

Muestra .pbix

Saludos
Liang
Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Hola @V-lianl-msft Gracias por la solución, tengo una pregunta,

Veo que en la fórmula el final de la fórmula es hasta finales de este año, pero en el próximo año esta fórmula sólo aparecerá hasta el año 2020?

¿Cuál es la forma de no tener que cambiar la fórmula cada año?

saludos

Xavi

Hola @XaviOV ,

Reemplazar 2020 por año (hoy())

Table 2 = 
ADDCOLUMNS (
    CROSSJOIN (
        CALENDAR ( DATE ( 2016, 1, 1 ), DATE ( YEAR(TODAY()), 12, 31 ) ),
       'Table (2)'  
    ),
    "DateTime", [Date]+[Time]
)

Saludos
Liang
Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Greg_Deckler
Super User
Super User

Tabla: GENERATESERIES(DATE(2016,1,1),DATE(2020,12,31),.04166666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@XaviOV también puede usar Power Query , pegar el código siguiente. Hay fecha de inicio y finalización que puede cambiar según sus necesidades.

let

    StartDate = #datetime(2020, 4, 1, 0, 0, 0),
    EndDate = #datetime(2020, 4, 30, 0, 0, 0),

    //Get the number of dates that will be required for the table
    GetDateCount = Duration.Days(EndDate - StartDate) + 1,

    //Take the count of dates and turn it into a list of dates
    GetDateList = List.DateTimes(StartDate, GetDateCount, #duration(1,1,0,0)),
    #"Converted to Table" = Table.FromList(GetDateList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "DateTime"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"DateTime", type datetime}})

in
    #"Changed Type"



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

fhill
Resident Rockstar
Resident Rockstar

Sería sugniffantly menos sobrecarga para construir una tabla de fechas con la función calendario, y una tabla de tiempo separada de 24 horas en un día. ¿Puedes entrar en más detalles de la meta final, tal vez podamos ayudar a llegar a un mejor enfoque?

Forrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors