Forum Discussion

Akvatraine02's avatar
Akvatraine02
New Member
5 years ago
Solved

Ayuda con DAX

Hola a todos, tengo una duda que no he podido resolver y quería ver si me podrían orientar:

Pasa que quiero hacer una columna, medida o parametro, donde yo pueda tener el promedio diario de horas en que no se trabaja filtrado por motivo.

 

Tabla:

Tengo una tabla con fecha, horas perdidas y motivo.

Al filtrar y sacar el promedio mensual de horas perdidas de 1 motivo, me calcula el promedio solo de los días en que existió ese motivo, y lo que yo necesito es que al filtrar por ese motivo el resto de motivos sean valor 0 pero que si entren en el promedio.

Por ejemplo: si yo en un mes en 3 días tuve perdidas por "motivo1", al filtrar y sacar el promedio lo saca así=

SUM(hrs perdidas "motivo1")/ 3 días.

Y lo que yo necesito es que con el filtro me calculé esto = SUM(hrs perdidas "motivo1")/ 30 días.

 

 

No se si se entendió..

  • Hi, Akvatraine02 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

     

    You may create a measure as below.

    Result = 
    DIVIDE(
        CALCULATE(
            SUM('Table'[Loss hours]),
            ALLSELECTED('Table')
        ),
        DISTINCTCOUNT('Table'[YearMonth])*30
    )

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Akvatraine02 , Try formula like

     

    MTD Sales = CALCULATE(SUM(Table[motivo1]),DATESMTD('Date'[Date]))/CALCULATE(distinctcount('Date'[Date]),DATESMTD('Date'[Date]), not(isblank(SUM(Table[motivo1]))))

  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Akvatraine02 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

     

    You may create a measure as below.

    Result = 
    DIVIDE(
        CALCULATE(
            SUM('Table'[Loss hours]),
            ALLSELECTED('Table')
        ),
        DISTINCTCOUNT('Table'[YearMonth])*30
    )

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.