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
pagrosse
Frequent Visitor

Filtrado de datos no votados en una medida

Hey chicos, estoy tratando de averiguar un filtro o una instrucción condicional que sólo devolverá los valores de presión cuando IsRunning-1. Sé cómo realizar esto en un contexto pivotado, pero no estoy seguro con la estructura de datos no votada de PowerBI. Podría simplemente pivotar los datos, pero por lo que he leído, Power BI es más eficaz con los datos de la estructura sin modificar.

Medida actual que devuelve todos los valores (cuando IsRunning es 0 o 1):

Presión: Calculate(average('Query1'[Value]), 'Query1'[Tag]-"Pressure")

¡Gracias!

Consulta1
DatetimeFechaHoraDíaValor
11/24/20 1:0011/24/20201:00IsRunning1
11/24/20 2:0011/24/20202:00IsRunning1
11/24/20 3:0011/24/20203:00IsRunning1
11/24/20 4:0011/24/20204:00IsRunning0
11/24/20 5:0011/24/20205:00IsRunning0
11/24/20 6:0011/24/20206:00IsRunning0
11/24/20 7:0011/24/20207:00IsRunning0
11/24/20 8:0011/24/20208:00IsRunning1
11/24/20 9:0011/24/20209:00IsRunning1
11/24/20 10:0011/24/202010:00IsRunning1
11/24/20 1:0011/24/20201:00Presión13.4
11/24/20 2:0011/24/20202:00Presión13.3
11/24/20 3:0011/24/20203:00Presión13.2
11/24/20 4:0011/24/20204:00Presión0.2
11/24/20 5:0011/24/20205:00Presión0.2
11/24/20 6:0011/24/20206:00Presión0.1
11/24/20 7:0011/24/20207:00Presión0.2
11/24/20 8:0011/24/20208:00Presión13.1
11/24/20 9:0011/24/20209:00Presión13.3
11/24/20 10:0011/24/202010:00Presión13.2

3 REPLIES 3
AlB
Super User
Super User

@pagrosse

Pivotar las columnas de etiqueta haría las cosas mucho más fáciles. Si hace esto en PQ:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdLNCsIwDMDxV5Geh0vS7ss38CZex45DvPSwsveXKcjiYpJjAz8KyX8cA2JNqSY44QUgVN83vR+f2bXc15yf+bGNwlTtFAmKTBUFFU2VBJWOCrhqBNWYqhVUa6pOUJ2pekH15jYGQQ2mQpDODLb7X8dtmUtZl3mbxHNy98FddBfCHbkb2Tn4ZUokGlMqYQzdmWi/KZ3wnfhLUW+gtnK4wvQC", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateTime = _t, Date = _t, Time = _t, Tag = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetime}, {"Date", type date}, {"Time", type time}, {"Tag", type text}, {"Value", type number}}),

    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Tag]), "Tag", "Value", List.Sum)
in
    #"Pivoted Column"

sería tan simple como:

Measure_pivoted =
CALCULATE ( AVERAGE ( 'Table2'[Pressure] ), 'Table2'[IsRunning] = 1 )

Por favor, marque la pregunta resuelta cuando haya terminado y considere dar un pulgar hacia arriba si las publicaciones son útiles.

Póngase en contacto conmigo de forma privada para obtener asistencia con cualquier necesidad de BI a gran escala, tutoría, etc.

Salud

SU18_powerbi_badge

AlB
Super User
Super User

Hola @pagrosse

Sin duda es una forma inusual de hacerlo. PRocessing los datos con PQ primero sería mejor conseguirlos en un formato más manejable. Usted puede hacer:

Measure = 
AVERAGEX (
    CALCULATETABLE (
        DISTINCT ( Table1[DateTime] ),
        Table1[Tag] = "IsRunning",
        Table1[Value] = 1
    ),
    CALCULATE ( SUM ( Table1[Value] ), Table1[Tag] = "Pressure" )
)

O

Measure2 = 
CALCULATE (
    AVERAGE ( Table1[Value] ),
    Table1[Tag] = "Pressure",
    CALCULATETABLE (
        DISTINCT ( Table1[DateTime] ),
        Table1[Tag] = "IsRunning",
        Table1[Value] = 1
    )
)

O

Measure3 =
AVERAGEX (
    FILTER (
        Table1,
        Table1[Tag] = "Pressure"
            && CALCULATE (
                SUM ( Table1[Value] ),
                Table1[Tag] = "IsRunning",
                ALLEXCEPT ( Table1, Table1[DateTime] )
            )
    ),
    Table1[Value]
)

Por favor, marque la pregunta resuelta cuando haya terminado y considere dar un pulgar hacia arriba si las publicaciones son útiles.

Póngase en contacto conmigo de forma privada para obtener asistencia con cualquier necesidad de BI a gran escala, tutoría, etc.

Salud

SU18_powerbi_badge

¡Impresionante! ¡Gracias! Yo los intento. Mencionas que esta es una manera inusual. ¿Debo pivotar todos estos datos para que sea más fácil de manipular? Esto me haría la vida más fácil, pero he leído que quieres todos tus datos en forma unpivoted ya que PowerBI está optimizado para manejar este tipo de estructura de datos

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.