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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
sunnypb
Frequent Visitor

DOUBT CALCULATION DAX % TIME

Hola amigos,

agradecería infinitamente su ayuda. Tengo el siguiente problema y no encuentro el cálculo. Tengo la siguiente tabla y necesito saber el % del tiempo que una casa está entre 17 y 24 (temperatura) y 40 y 60 (humedad), cuando se cumple esa condición se puede decir que la casa está dentro del rango de confort.

 

DUDA_CONFORT.JPG

 

He creado las medidas siguientes

 

Confort = PROMEDIO('lecturas confort'[LECTURA])
Humedad = CALCULATE([Confort], 'lecturas confort'[TIPO_SONDA] IN { "Humedad" })
Temperatura = CALCULAR( [Confort],'lecturas confort'[TIPO_SONDA] IN { "Temperatura" })
 
y para el cáculo del % dentro del rango de confort
 
% RANGO COMPORTAMIENTO =

var porcent=
DIVIDIR(
    COUNTROWS(
        FILTER('lecturas confort',
            INTERRUPTOR(
                VERDADERO(),
                [Temperatura]>=17
&&[Temperatura]<=25
                && [Humedad]>=40
&&[Humedad]<=60, "EN_RANGO",
             "FUERA_DE_RANGO"
            ) = "EN_RANGO"
        )
    ),
COUNTROWS('lecturas confort')
)
var resultado=
if (ISBLANK(porcent),0,porcent)
Resultado de retorno
 
Pero no funciona para mí, no tengo mucha experiencia con Dax. Agradecería su ayuda. Muchas gracias.
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @sunnypb ,

 

Please try:

Percentage =
VAR _a =
    ADDCOLUMNS (
        'Table',
        "Comfort",
            IF (
                ( 'Table'[TIPO SONDA] = "TEMPERATURA"
                    && [LECTURA] <= 25
                    && [LECTURA] >= 17 )
                    || ( 'Table'[TIPO SONDA] = "HUMEDAD"
                    && [LECTURA] <= 60
                    && [LECTURA] >= 40 ),
                "Comfortable",
                "Uncomfortable"
            )
    )
RETURN
    DIVIDE (
        COUNTROWS ( FILTER ( _a, [Comfort] = "Comfortable" ) ),
        COUNTROWS ( 'Table' )
    )

Output:

vjianbolimsft_0-1666667267885.png

Best Regards,

Jianbo Li

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

View solution in original post

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @sunnypb ,

 

Please try:

Percentage =
VAR _a =
    ADDCOLUMNS (
        'Table',
        "Comfort",
            IF (
                ( 'Table'[TIPO SONDA] = "TEMPERATURA"
                    && [LECTURA] <= 25
                    && [LECTURA] >= 17 )
                    || ( 'Table'[TIPO SONDA] = "HUMEDAD"
                    && [LECTURA] <= 60
                    && [LECTURA] >= 40 ),
                "Comfortable",
                "Uncomfortable"
            )
    )
RETURN
    DIVIDE (
        COUNTROWS ( FILTER ( _a, [Comfort] = "Comfortable" ) ),
        COUNTROWS ( 'Table' )
    )

Output:

vjianbolimsft_0-1666667267885.png

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.