Forum Discussion

Yonah's avatar
Yonah
Icon for Helper II rankHelper II
1 year ago
Solved

Ignore selection of certain value

On my report page, I have a bar chart with different countries and a total column.

I did this via

‘All_Countries_Plan = UNION(Distinct(Account[Country]),{’Gesamt"})’

Where ‘Gesamt’ = Total.

 

If the user now clicks on Total, the other visuals on the page should not change, they should only change when the user clicks on a country in the bar chart.

 

My idea would be to arrange a list of countries,

that shows all countries when Total is selected.

And otherwise, the corresponding countries.

 

I wanted to use the following DAX:

IF(SELECTEDVALUE(‘All_Country_Plan’[Country]) = ‘Total’,

ALL(‘All_Country_Plan’),

VALUES(‘All_Country_Plan’))

 

And then set the conditions in the filter panel to is not blank.

 

But unfortunately it does not work, if nothing is selected, as well as if Total is selected I get the error, ‘A table with multiple values was returned, although a single value was expected’.

 

Is there a workaround for this error without changing the measures used in the visals.

 

Thank you very much

 

  • Hi  Yonah 

     

    Measures must always return a scalar value one way or another.  These two return a table with multiple values.

    ALL(‘All_Country_Plan’)
    
    VALUES(‘All_Country_Plan’))

     

    I am not sure what exactly you're trying to calculate but this is the correct use:

    IF (
        -- Check if the selected country is "Total"
        SELECTEDVALUE ( 'All_Country_Plan'[Country] ) = "Total",
        -- If "Total" is selected, calculate the measure ignoring all filters on 'All_Country_Plan'
        CALCULATE (
            [my measure],
            ALL ( 'All_Country_Plan' )
        ),
        -- Otherwise, return the measure as is, keeping existing filters
        [my measure]
    )
    

     

2 Replies

  • Hi  Yonah 

     

    Measures must always return a scalar value one way or another.  These two return a table with multiple values.

    ALL(‘All_Country_Plan’)
    
    VALUES(‘All_Country_Plan’))

     

    I am not sure what exactly you're trying to calculate but this is the correct use:

    IF (
        -- Check if the selected country is "Total"
        SELECTEDVALUE ( 'All_Country_Plan'[Country] ) = "Total",
        -- If "Total" is selected, calculate the measure ignoring all filters on 'All_Country_Plan'
        CALCULATE (
            [my measure],
            ALL ( 'All_Country_Plan' )
        ),
        -- Otherwise, return the measure as is, keeping existing filters
        [my measure]
    )
    

     

    • Yonah's avatar
      Yonah
      Icon for Helper II rankHelper II

      danextian 
      I want to achieve exaktly, what you are doing with your soulotion, 
      but I'dont want to modify all my measuers. 
      There for, I want to have a scalar value  (List of Countrys) that don't change if "Gesamt" is selected.
      But its look like, I have to change the measuers instad.