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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Syndicate_Admin
Administrator
Administrator

¿Necesita ayuda con el conteo de días, por favor?

Tengo un refugio para perros y necesito contar los días que cada perrera está vacía. Cada fila es el tiempo que un perro está en una perrera.

Necesito la diferencia entre la fecha de finalización de un perro que deja la perrera y la fecha de inicio del próximo perro que se incorpora. Si no hay una fecha de inicio para que el próximo perro se una, necesito que se calcule la fecha de hoy para el conteo de días, por favor.

Por ejemplo, utilizando la siguiente tabla:

Perrera 1 = 0 días

Perrera 2 = 285 días

Perrera 3 = 186 días

Perrera 4 = 0 días

PerreraPerroFecha de inicioFecha final
1Máximo24/02/202404/03/2024
1Charles04/03/202425/07/2024
1Morado25/07/2024
2Milo01/06/202426/08/2024
3Rex08/09/202410/10/2024
4Pajarito01/11/202430/12/2024
4Bob30/12/2024

Gracias

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

¿Puedo tomar prestado su calendario por un minuto? Me gustaría unos días más...

lbendlin_0-1741889242151.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY69CoQwEIRf5Ugd2J+op+1deza2YhG5gIGAoI2P78agEmEJzMy3k+17RUqr1m7ycgHIwMiFCBRhkhh0or6TXYJb81DWSsB3Tv58sHmi1etIOf7mwxxLCLC6SirA+i4xYnUuHiUuNidFCDIXFa2PX/7epTqiEzQC8gOcxzw4Thp2", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Kennel = _t, Dog = _t, #"Start Date" = _t, #"End Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Start Date", type date}, {"End Date", type date}},"en-GB"),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Start Date", Order.Descending}}),
    #"Grouped Rows" = Table.Group(#"Sorted Rows", {"Kennel"}, {{"Rows", each _, type table [Kennel=nullable text, Dog=nullable text, Start Date=nullable date, #"End Date "=nullable date]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Kennel Empty Days", each Int64.From(if Table.RowCount([Rows])>1 then [Rows]{0}[Start Date] - [Rows]{1}[End Date] else Date.From(DateTime.LocalNow()) - [Rows]{0}[End Date]),Int64.Type),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Rows"})
in
    #"Removed Columns"

Cómo usar este código: Cree una nueva consulta en blanco. Haga clic en "Editor avanzado". Reemplace el código en la ventana con el código proporcionado aquí. Haga clic en "Listo". Una vez que haya examinado el código, reemplace todo el paso de origen con su propio código fuente.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors