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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
dhersz
Frequent Visitor

Question about VALUES function

Hello,

 

I'm running through a problem with the usage of VALUES function, which is exactly what this page (https://msdn.microsoft.com/en-us/library/ee634547.aspx) lists as a remark of the function: it is filtering my results, where I want it unfiltered. The page also says "To return all of the cities, regardless of existing filters, you must use the ALL function to remove filters from the table. The second example demonstrates use of ALL with VALUES.", but there is not a second example...

 

Is there any place where I could read about using the VALUES and ALL function together?

 

My code right now looks like this:

 

MédiasSemFiltro = SWITCH(VALUES('Ordem etapas'[Etapa]),
                            "EM PROSPECÇÃO", 'CRM - Acompanhamento geral'[SFMédiaProspecção],
                            "AGENDANDO VISITA", 'CRM - Acompanhamento geral'[SFMédiaAgendamento],
                            "1ª VISITA", 'CRM - Acompanhamento geral'[SFMédia1Visita],
                            "PROPOSTA", 'CRM - Acompanhamento geral'[SFMédiaProposta],
                            "2ª VISITA", 'CRM - Acompanhamento geral'[SFMédia2Visita],
                            "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
                            "CADASTROS", 'CRM - Acompanhamento geral'[SFMédiaCadastros],
                            "PROPOSTA DE COMPRA", 'CRM - Acompanhamento geral'[SFMédiaPropostaDeCompra],
                            "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
                            "CONCLUÍDO", 'CRM - Acompanhamento geral'[SFMédiaÚltimaFatura],
                            "DESCONTINUADO", 'CRM - Acompanhamento geral'[SFMédiaDescontinuamento],
                            BLANK())

I've also tried to use ALL and DISTINCT instead of VALUES, but they either return me this error "MdxScript(Model) (38, 61) A table of multiple values was supplied where a single value was expected." (in the case of ALL) or it keeps the filtered values (in the case of DISTINCT).

 

Could any of you enlighten me on this subject?

 

Best regards

1 ACCEPTED SOLUTION

@dhersz

 

If you are using a MEASURE...replace VALUES with SELECTEDVALUE

 

i.e.

 

MédiasSemFiltro =
SWITCH (
    SELECTEDVALUE ( 'Ordem etapas'[Etapa] ),
    "EM PROSPECÇÃO", 'CRM - Acompanhamento geral'[SFMédiaProspecção],
    "AGENDANDO VISITA", 'CRM - Acompanhamento geral'[SFMédiaAgendamento],
    "1ª VISITA", 'CRM - Acompanhamento geral'[SFMédia1Visita],
    "PROPOSTA", 'CRM - Acompanhamento geral'[SFMédiaProposta],
    "2ª VISITA", 'CRM - Acompanhamento geral'[SFMédia2Visita],
    "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
    "CADASTROS", 'CRM - Acompanhamento geral'[SFMédiaCadastros],
    "PROPOSTA DE COMPRA", 'CRM - Acompanhamento geral'[SFMédiaPropostaDeCompra],
    "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
    "CONCLUÍDO", 'CRM - Acompanhamento geral'[SFMédiaÚltimaFatura],
    "DESCONTINUADO", 'CRM - Acompanhamento geral'[SFMédiaDescontinuamento],
    BLANK ()
)

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

Hi @dhersz

 

If you are using a calculated column, you should NOT use VALUES or ALL at all.

 

MédiasSemFiltro =
SWITCH (
    'Ordem etapas'[Etapa],
    "EM PROSPECÇÃO", 'CRM - Acompanhamento geral'[SFMédiaProspecção],
    "AGENDANDO VISITA", 'CRM - Acompanhamento geral'[SFMédiaAgendamento],
    "1ª VISITA", 'CRM - Acompanhamento geral'[SFMédia1Visita],
    "PROPOSTA", 'CRM - Acompanhamento geral'[SFMédiaProposta],
    "2ª VISITA", 'CRM - Acompanhamento geral'[SFMédia2Visita],
    "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
    "CADASTROS", 'CRM - Acompanhamento geral'[SFMédiaCadastros],
    "PROPOSTA DE COMPRA", 'CRM - Acompanhamento geral'[SFMédiaPropostaDeCompra],
    "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
    "CONCLUÍDO", 'CRM - Acompanhamento geral'[SFMédiaÚltimaFatura],
    "DESCONTINUADO", 'CRM - Acompanhamento geral'[SFMédiaDescontinuamento],
    BLANK ()
)

 

@dhersz

 

If you are using a MEASURE...replace VALUES with SELECTEDVALUE

 

i.e.

 

MédiasSemFiltro =
SWITCH (
    SELECTEDVALUE ( 'Ordem etapas'[Etapa] ),
    "EM PROSPECÇÃO", 'CRM - Acompanhamento geral'[SFMédiaProspecção],
    "AGENDANDO VISITA", 'CRM - Acompanhamento geral'[SFMédiaAgendamento],
    "1ª VISITA", 'CRM - Acompanhamento geral'[SFMédia1Visita],
    "PROPOSTA", 'CRM - Acompanhamento geral'[SFMédiaProposta],
    "2ª VISITA", 'CRM - Acompanhamento geral'[SFMédia2Visita],
    "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
    "CADASTROS", 'CRM - Acompanhamento geral'[SFMédiaCadastros],
    "PROPOSTA DE COMPRA", 'CRM - Acompanhamento geral'[SFMédiaPropostaDeCompra],
    "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
    "CONCLUÍDO", 'CRM - Acompanhamento geral'[SFMédiaÚltimaFatura],
    "DESCONTINUADO", 'CRM - Acompanhamento geral'[SFMédiaDescontinuamento],
    BLANK ()
)

That's exactly it... Thank you very much.

 

I was also calculating the measures like so:

Média1Visita = CALCULATE(AVERAGE('CRM - Acompanhamento geral'[Duração1Visita]))

So I changed to:

Média1Visita = CALCULATE(AVERAGE('CRM - Acompanhamento geral'[Duração1Visita]), ALLSELECTED('CRM - Acompanhamento geral'))

Which probably also helped Smiley LOL

@dhersz

 

You can also use VALUES function in the MEASURE.. but then you would have to take care of the total row by adding "HASONEVALUE"

 

i.e. try

 

MédiasSemFiltro =
IF (
    HASONEVALUE ( 'Ordem etapas'[Etapa] ),
    SWITCH (
        VALUES ( 'Ordem etapas'[Etapa] ),
        "EM PROSPECÇÃO", 'CRM - Acompanhamento geral'[SFMédiaProspecção],
        "AGENDANDO VISITA", 'CRM - Acompanhamento geral'[SFMédiaAgendamento],
        "1ª VISITA", 'CRM - Acompanhamento geral'[SFMédia1Visita],
        "PROPOSTA", 'CRM - Acompanhamento geral'[SFMédiaProposta],
        "2ª VISITA", 'CRM - Acompanhamento geral'[SFMédia2Visita],
        "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
        "CADASTROS", 'CRM - Acompanhamento geral'[SFMédiaCadastros],
        "PROPOSTA DE COMPRA", 'CRM - Acompanhamento geral'[SFMédiaPropostaDeCompra],
        "FECHAMENTO", 'CRM - Acompanhamento geral'[SFMédiaFechamento],
        "CONCLUÍDO", 'CRM - Acompanhamento geral'[SFMédiaÚltimaFatura],
        "DESCONTINUADO", 'CRM - Acompanhamento geral'[SFMédiaDescontinuamento],
        BLANK ()
    )
)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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