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
Maheshwari
New Member

contar la aparición de valores en una columna para un rango de valores que cambia dinámicamente

Ejemplo :Si tengo valores de 1 a 100 como 1,1,5,8,3,3,7,8,1,2... en columna. Necesidad de contar la ocurrencia de valores de 1 a 5, 5 a 10 y así sucesivamente. (Diga aquí... 1 a 5 --> 8 (1,1,5,8,3,31,2), 5 a 10 -->3 (8,7,8)). ¿Cómo establecer la variable dynaimc usando DAX o esto podría hacerse en powerquery?

5 REPLIES 5
Maheshwari
New Member

Gracias a todos.... Probé el primero y intentaré permanecer dos... entre he intentado la segmentación estática que funciona bien para mi necesidad

Hola @Maheshwari

Tú también puedes probar mi camino. Agregue una columna Type por columna condicional en el editor de consultas Power y, a continuación, muestre los resultados en la tabla visual por función count.

1.png

Haga clic en Cerrar y aplicar. A continuación, cree un objeto visual de tabla por columna Tipo y columna de recuento de valores.

2.png

Puede descargar el archivo pbix desde este enlace: File.pbix

Saludos

Rico Zhou

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

mahoneypat
Employee
Employee

Esto sería un buen uso de la característica group/bin en Power BI.

Usar agrupación y binning en Power BI Desktop - Power BI ? Documentos de Microsoft

saludos

palmadita





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


CNENFRNL
Community Champion
Community Champion

@Maheshwari, la solución más fácil se encuentra en Excel, nuestro oldie pero goodie; FREQUENCY() es una especie de listo para comer para tal pregunta.

Aquí está mi solución detallada en PQ; Hice la variable span.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY67EcAgDEN3oU4R/AEzi4/91wjnR5EGnfUs4czWre0nm3qJS8nE7Jij3mV/NDE9YIv9DtOSYApK9GWTnN3OaxIYBIQbBBYwY3J+FzplUo2cU/YH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}}),

    ds = List.Buffer(List.Sort(#"Changed Type"[Value], Order.Ascending)),
    span = 5,
    Grouped = List.Accumulate(
        ds,
        {{0, 0}},// {{upper boudary, counter}, {}, {}, ...}
        (s,c) => if c>s{0}{0} then {{Number.RoundUp(c/span)*span, s{0}{1}+1}} & List.RemoveFirstN(s) & {{c}} else List.RemoveLastN(s) & {s{s{0}{1}} & {c}}
    ),
    Expanded = Table.FromRecords(List.Transform(List.RemoveFirstN(Grouped), each [Lower Boundary=#"Upper Boundary"-span, Upper Boundary=Number.RoundUp(List.Max(_)/span)*span, Count=List.Count(_)]))
in
    Expanded

Screenshot 2020-11-28 172547.pngScreenshot 2020-11-28 172742.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Ashish_Mathur
Super User
Super User

Hola

La respuesta debe ser 7 y 3 (no 8 y 3). Puede descargar mi archivo PBI desde aquí.

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.