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
LudivineLOU
Helper I
Helper I

recuento - repeticións de lista

Hola

Me gustaría contar el número de repeticiones en función de mis columnas Purchase Doc. en PoweBI

En Excel, utilizo la fórmula NB.SI

Puro. Doc. ItmFechaQtyNúmero
60113.02.202021
60113.02.202022
60126.09.201983
60115.11.201984
60125.10.2019105
60215.11.2019101
60228.11.201972
60210.12.201973
60223.12.2019104
60220.01.2020105
60321.02.202051
60323.03.2020102
60314.04.2020103
60429.05.2020101
60426.06.2020102
60726.09.201931
60722.04.202012
61010.09.201921
61025.10.201952
61215.11.201951
61328.11.201981

Mi objetivo es calcular aumatically las columnas "Número"

¿Tiene una idea de la función DAX que se va a utilizar?

Muchas gracias por su ayuda, Saludos,

5 REPLIES 5
LudivineLOU
Helper I
Helper I

Muchas gracias a todos, funciona 🙂

Que tengas un buen día

Saludos

Ashish_Mathur
Super User
Super User

Hola

Prueba este código M

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Pur. Doc. Itm", Int64.Type}, {"date", type date}, {"qty", Int64.Type}}),
    Partition = Table.Group(#"Changed Type", {"Pur. Doc. Itm"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
    #"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"date", "qty", "Index"}, {"date", "qty", "Index"})
in
    #"Expanded Partition"

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yingjl
Community Support
Community Support

Hola @LudivineLOU ,

Para obtener el mismo resultado esperado que la tabla, primero debe agregar una columna de índice manualmente en la consulta power:

index column.png

A continuación, cree una columna calculada como esta:

Column =
CALCULATE (
    COUNT ( 'Table'[Pur.Doc.Itm] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Pur.Doc.Itm] ),
        'Table'[Index] <= EARLIER ( 'Table'[Index] )
    )
)

Obtendrá el resultado esperado:

result.png

Adjunto mi archivo de muestra que espera ayudarle, por favor compruébelo y pruébelo: count.pbix

Best Looks,
Yingjie Li

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

amitchandak
Super User
Super User

@LudivineLOU , A medida que se repiten las fechas, es posible que necesite una columna de índice. o usar rango con un desempate

countx(filter(Table, table[Pur. Doc.] Earlier(table[Pur. Doc.] ) && table[Itm date] <-earlier(table[Itm date])
&& table[index] <-earlier(table[index]) ),table[Pur. Doc.] )

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

Para rango Consulte estos enlaces
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Greg_Deckler
Super User
Super User

@LudivineLOU - Necesitas a Cthulhu. https://community.powerbi.com/t5/Quick-Measures-Gallery/Cthulhu/m-p/509739#M211


@ 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...

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.