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
Anonymous
Not applicable

Necesita ayuda con la condición para null

Hola amigos, tengo una columna donde son años de nacimiento de los usuarios, pero también hay valores nulos. Necesito hacer una condición donde necesito encontrar si el usuario es "mayor de 50 años", "younder 50 años" o "no se puede calcular" debido al valor nulo. Intenté algo como esto:

Mayores o menores de 50 años
Interruptor ( True();
2020 - 'Data 2015, 2016'[año de nacimiento] > 50; "Más de 50 años";
'Data 2015, 2016'[año de nacimiento] - nulo; "No se puede calcular";
2020 - «Data 2015, 2016»[año de nacimiento] < 50; "Jóvenes 50 años")
Pero no puede controlar con null valor. ¿Puede ayudarme a crear una condición para el valor nulo?
1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@leenka

Hola

Tratar

Older or younger 50 years =
Switch ( True();
2020 - 'Data 2015, 2016'[birth year] > 50; "More then 50 years";
ISBLANK('Data 2015, 2016'[birth year]); "Cant calculate";
2020 - 'Data 2015, 2016'[birth year] < 50; "Younger 50 years")

o, si el campo devuelve null como texto:

Older or younger 50 years =
Switch ( True();
2020 - 'Data 2015, 2016'[birth year] > 50; "More then 50 years";
'Data 2015, 2016'[birth year] = "null"; "Cant calculate";
2020 - 'Data 2015, 2016'[birth year] < 50; "Younger 50 years")

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hola, @leenka

Si toma la respuesta de alguien, márquela como la solución para ayudar a los otros miembros que tienen los mismos problemas a encontrarlo más rápidamente. Si no, avísame y trataré de ayudarte más. Gracias.

Saludos

Allan

v-alq-msft
Community Support
Community Support

Hola, @leenka

Según su descripción, creé datos para reproducir su escenario.
Mesa:

f1.png

Puede probar las siguientes columnas calculadas.

Older or younger 50 years = 
SWITCH(
    TRUE(),
    'Table'[Age]>=50,"More than 50 years",
    'Table'[Age]<50&&'Table'[Age]>0,"Younger than 50 years",
    'Table'[Age]=BLANK(),"Cant calculate",
    BLANK()
)

or

Older or younger 50 years 2 = 
IF(
    'Table'[Age]>=50,
    "More then 50 years",
    IF(
        'Table'[Age]>0&&'Table'[Age]<50,
        "Younger than 50 years",
        IF(
            'Table'[Age]=BLANK(),
            "Cant calculate",
            BLANK()
        )
    )
)

Resultado:

f2.png

Saludos

Allan

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

nandukrishnavs
Super User
Super User

@leenka
Prueba esto

Older or younger 50 years = 
var age= 2020- 'Data 2015'[birth year]
var result = IF(ISBLANK('Data 2015'[birth year]),"Cant calculate",IF(age>50,"Greater","less"))
return result


Regards,
Nandu Krishna

az38
Community Champion
Community Champion

@leenka

Hola

Tratar

Older or younger 50 years =
Switch ( True();
2020 - 'Data 2015, 2016'[birth year] > 50; "More then 50 years";
ISBLANK('Data 2015, 2016'[birth year]); "Cant calculate";
2020 - 'Data 2015, 2016'[birth year] < 50; "Younger 50 years")

o, si el campo devuelve null como texto:

Older or younger 50 years =
Switch ( True();
2020 - 'Data 2015, 2016'[birth year] > 50; "More then 50 years";
'Data 2015, 2016'[birth year] = "null"; "Cant calculate";
2020 - 'Data 2015, 2016'[birth year] < 50; "Younger 50 years")

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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.