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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Janchieta
New Member

Error with VALUES Function When No Filter is Applied and Issue with ADDCOLUMNS in DAX Measure

I'm trying to create a DAX measure that calculates reliability, but I’m encountering an issue. The goal is to make the measure work when one or more equipment items are selected. However, when no equipment filter is applied, it throws an error in the graph. I need help adapting the formula to handle this case properly.

Here’s the original code:

Confiabilidade_Sistema =
VAR t = SELECTEDVALUE(Tabela_TTF[TTF]) -- Time to failure (in hours)
VAR Equipamentos = VALUES(TTF[Equipamento Corrigido])
VAR Confiabilidades =
    ADDCOLUMNS(
        Equipamentos,
        "Confiabilidade",
        VAR Beta = CALCULATE([b_eq], TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
        VAR Eta = CALCULATE(EXP(-[a_eq] / Beta), TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
        RETURN IF(NOT(ISBLANK(Beta)) && NOT(ISBLANK(Eta)), EXP(-POWER(t / Eta, Beta)), 1)
    )
RETURN
1 - PRODUCTX(Confiabilidades, 1 - [Confiabilidade])


Now, I’m trying to adapt the formula to handle both cases — when equipment is filtered and when no filter is applied:

Confiabilidade_Sistema =

VAR t = SELECTEDVALUE(Tabela_TTF[TTF]) -- Time to failure (in hours)
VAR Equipamentos =
    IF(
        ISFILTERED(TTF[Equipamento Corrigido]),
        VALUES(TTF[Equipamento Corrigido]),
        FILTER(
            VALUES(TTF[Equipamento Corrigido]),
            NOT(ISBLANK(TTF[a_eq]))
        )
    )
VAR Confiabilidades =
    ADDCOLUMNS(
        Equipamentos,
        "Confiabilidade",
        VAR Beta = CALCULATE([b_eq], TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
        VAR Eta = CALCULATE(EXP(-[a_eq] / Beta), TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
        RETURN IF(NOT(ISBLANK(Beta)) && NOT(ISBLANK(Eta)), EXP(-POWER(t / Eta, Beta)), 1)
    )
RETURN
1 - PRODUCTX(Confiabilidades, 1 - [Confiabilidade]) -- Calculates system reliability


However, it returns the following error: "The ADDCOLUMNS function expected a table expression for the '' argument, but a string or numeric expression was used."

The issue arises when no equipment is selected. If any equipment is selected, the graph works fine. Could you help me fix this issue?

 
Janchieta_1-1734989400129.pngJanchieta_2-1734989422395.png

 

 

2 ACCEPTED SOLUTIONS
SachinNandanwar
Super User
Super User

Hi,
Can you try CALCULATETABLE instead of FILTER ?

VAR Equipamentos =
    IF(
        ISFILTERED(TTF[Equipamento Corrigido]),
        VALUES(TTF[Equipamento Corrigido]),
        CALCULATEDTABLE(
            VALUES(TTF[Equipamento Corrigido]),
            NOT(ISBLANK(TTF[a_eq]))
        )
    )

 



Regards,
Sachin
Check out my Blog

View solution in original post

anmolmalviya05
Super User
Super User

Hi @Janchieta , Please try the below updated measure:


Confiabilidade_Sistema =
VAR t = SELECTEDVALUE(Tabela_TTF[TTF]) -- Time to failure (in hours)
VAR Equipamentos =
IF(
ISFILTERED(TTF[Equipamento Corrigido]),
VALUES(TTF[Equipamento Corrigido]),
FILTER(
ALL(TTF[Equipamento Corrigido]),
NOT(ISBLANK(CALCULATE([a_eq])))
)
)
VAR Confiabilidades =
ADDCOLUMNS(
Equipamentos,
"Confiabilidade",
VAR Beta = CALCULATE([b_eq], TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
VAR Eta = CALCULATE(EXP(-[a_eq] / Beta), TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
RETURN IF(NOT(ISBLANK(Beta)) && NOT(ISBLANK(Eta)), EXP(-POWER(t / Eta, Beta)), 1)
)
RETURN
IF(
ISBLANK(t),
BLANK(), -- Handles cases where TTF is not available
1 - PRODUCTX(Confiabilidades, 1 - [Confiabilidade]) -- Calculates system reliability
)

View solution in original post

2 REPLIES 2
anmolmalviya05
Super User
Super User

Hi @Janchieta , Please try the below updated measure:


Confiabilidade_Sistema =
VAR t = SELECTEDVALUE(Tabela_TTF[TTF]) -- Time to failure (in hours)
VAR Equipamentos =
IF(
ISFILTERED(TTF[Equipamento Corrigido]),
VALUES(TTF[Equipamento Corrigido]),
FILTER(
ALL(TTF[Equipamento Corrigido]),
NOT(ISBLANK(CALCULATE([a_eq])))
)
)
VAR Confiabilidades =
ADDCOLUMNS(
Equipamentos,
"Confiabilidade",
VAR Beta = CALCULATE([b_eq], TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
VAR Eta = CALCULATE(EXP(-[a_eq] / Beta), TTF[Equipamento Corrigido] = EARLIER(TTF[Equipamento Corrigido]))
RETURN IF(NOT(ISBLANK(Beta)) && NOT(ISBLANK(Eta)), EXP(-POWER(t / Eta, Beta)), 1)
)
RETURN
IF(
ISBLANK(t),
BLANK(), -- Handles cases where TTF is not available
1 - PRODUCTX(Confiabilidades, 1 - [Confiabilidade]) -- Calculates system reliability
)

SachinNandanwar
Super User
Super User

Hi,
Can you try CALCULATETABLE instead of FILTER ?

VAR Equipamentos =
    IF(
        ISFILTERED(TTF[Equipamento Corrigido]),
        VALUES(TTF[Equipamento Corrigido]),
        CALCULATEDTABLE(
            VALUES(TTF[Equipamento Corrigido]),
            NOT(ISBLANK(TTF[a_eq]))
        )
    )

 



Regards,
Sachin
Check out my Blog

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.