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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors