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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
harshagraj
Post Partisan
Post Partisan

Fecha máxima de cada filtro mes

Hola a todos tengo una columna llamada Fecha de informe y necesito filtrar la fecha máxima de cada mes y quiero aplicar este filtro en el nivel de página. Por favor, ayudarprt.JPG

10 REPLIES 10
amitchandak
Super User
Super User

@harshagraj , mejor que tenga la columna del año del mes en la tabla o tabla de fechas

calculate([measure],values(Table[Month-Year]),filter(Table,Table[Report] ?LASTNONBLANKVALUE(Table[Month-Year], max(Table[Report]))))

Greg_Deckler
Super User
Super User

Bueno, podrías crear una columna como esta:

Column =
  VAR __Max = 
    MAXX(
      FILTER(
        'Table',
        MONTH([REPORT_DATE]) = MONTH(EARLIER([REPORT_DATE])) && 
          YEAR([REPORT_DATE]) = YEAR(EARLIER([REPORT_DATE]))
      ),
      [REPORT_DATE]
    )
RETURN
  IF([REPORT_DATE] = __Max,1,0)


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

¡Muchas gracias @Greg_Deckler funcionó! pero por si acaso alguna posibilidad de hacer esto en el nivel de consulta? para que pueda ahorrar el tiempo de actualización.

@harshagraj Tal vez @ImkeF o @edhans tenga un pensamiento aquí.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

¿Es esto lo que necesitas? ¿Una columna de Power Query que tiene la fecha máxima de los datos para cada mes determinado?
EDITAR: Agregué una columna true/false de [IsMaxDate] en el código M para agregar true si ithe date es la fecha máxima, o false si no. Pero no me molesté en rehacer la imagen.

2020-05-25 12_05_49-Untitled - Power Query Editor.png

Mi solución agrega una columna temporal denominada YearMonth (formato AAAAMM) para realizar una selección de filas. Aquí está el código M.

La clave es el paso "Fecha máxima añadida".

  1. Tiene el récord actual YearMonth en una variable
  2. Crea una tabla en memoria de todas las fechas de ese mes (mes)
  3. Encuentra la fecha máxima en esa tabla
  4. convierte esa fecha en un valor en la nueva columna Fecha máxima

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZDBDYAwDAN36RsptYHSzlKx/xqEfrAf/HI5WbEyZ2Hswcpa7m0WMJCEsYg5muOlsosLNqPuuaq5tRDZ7KKXOT+HgDbNI4fItDDk0KjVY/w7mMN6zkv3Aw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"Added YearMonth" = Table.AddColumn(#"Changed Type", "YearMonth", each Date.Year([Date])*100 + Date.Month([Date]), Int64.Type),
    #"Added Max Date" =
        Table.AddColumn(#"Added YearMonth", "Max Date", 
        each
            let
                varDate = [YearMonth]
            in
            Table.Max(
                Table.SelectRows(#"Added YearMonth", each [YearMonth] = varDate)
                , "Date"
            )[Date]
, type date),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Max Date",{"Date", "Max Date"}),
    #"Added IsMaxDate" = Table.AddColumn(#"Removed Other Columns", "IsMaxDate", each [Date] = [Max Date], type logical)
in
    #"Added IsMaxDate"

1) En Power Query, seleccione Nuevo origen y, a continuación, Consulta en blanco
2) En la cinta inicio, seleccione el botón "Editor avanzado"
3) Retire todo lo que ve, luego pegue el código M que le he dado en ese cuadro.
4) Pulse Hecho



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Buenos días. Es interesante lo que aquí planteas. Yo busco algo similar pero no la fecha máxima por mes, sino, la fecha max de toda esa columna.

 

Como podría lograr eso?

Hola @edhans gracias por la solución, pero estoy entrando en el siguiente paso.

"Mes del Año Añadido" - Tabla.AddColumn('Changed Type3", "YearMonth", cada Date.Year([REPORT_DATE])*100 + Date.Month([REPORT_DATE])),

"Añadida Fecha Máxima"
Table.AddColumn(''Agregado YearMonth', "Max Date',
Cada
Dejar
varDate á [YearMonth]
En
Table.Max(
Table.SelectRows("Added YearMonth", cada [YearMonth] á varDate)
, "Fecha"
)[REPORT_DATE]
, escriba la fecha),
"Añadido IsMaxDate" - Table.AddColumn('Added Max Date', "IsMaxDate", cada [REPORT_DATE] á [Max Date], tipo lógico)
tempsnip.jpg

¿Qué dice el error? Haga clic en el cuadro gris junto a la palabra Error y PQ le mostrará el contenido del error en la parte inferior de su archivo.

Puede deshacerse de la parte ", escriba date". Si no devuelve una fecha legítima, se producirá un error para intentar establecer el tipo de fecha como una fecha.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hola @edhans he eliminado la fecha de tipo y por favor vea el siguiente error.sni.JPG

@harshagraj - echa un vistazo a este artículo. Puede ayudar. Mi solución no es definitivamente para grandes conjuntos de datos.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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