Loading

Creating a Condition that Returns Different Results When "All" is Selected in a Filter

Publiseringsdato: Apr 13, 2024
Oppgave
How to create a calculated field that returns a TRUE when "All" is selected in a filter, so that this calculated field can be used as a condition in another calculation.
Trinn

Option 1: When "All" is selected in a dimension filter

Create a calculated field with a name like "All selected?" with a calculation similar to the following:

TOTAL( COUNTD( [Category] ) ) = SUM( { FIXED : COUNTD( [Category] ) } )
 

  • The above calculation will return True when "All" is selected in the [Category] filter. ([Category] is a dimension specific to the Superstore Sample data source. )
  • The TOTAL(COUNTD()) expression counts the number of values of [Category] in the view.
  • The FIXED expression counts the total number of values of [Category] in the entire data set.
  • When no dimension is included after FIXED then the expression will be evaluated over the whole data set.

Option 2: When "All" is selected in a parameter

  1. In the data pane, right-click [Category] and select Create Parameter.
  2. In the Create Parameter dialog box do the following and click OK.
    1. In the Name text box, type a name. In this example I will call the parameter "Category Parameter".
    2. Add "All" to the List of Values.
    3. Right-click [Category Parameter] in the data pane and select Show Parameter Control.
  3. Create a calculated field with a name similar to "Category Parameter Filter" with a calculation similar to the following:
    [Category] = [Category Parameter]
    OR
    [Category Parameter] = "All"
    
  4. Drag [Category Parameter Filter] to the Filters shelf. 
  5. In the Filter dialog, check True and click OK.
  6. Create a calculated field with a name like "All Selected (parameter)" with a calculation similar to the following:
    [Category Parameter] = "All"
    
Flere ressurser
Option 1 may require adjusting the calculation or Compute Using settings every time dimensions are added or removed from the view.

If Option 1 is not returning the expected results, it may be necessary to change how the table calculation is computed. For more information, see Transform Values with Table Calculations.

Knowledge-artikkelnummer

001456655

Vedlegg

All selected or not_v2018.1.twbx

1182 KB

 
Laster
Salesforce Help | Article