Forum Discussion
Default value in a KPI visual when no slicer selected
- 9 months ago
Hello,
You can consider using the function ISFILTERED. So something like:VAR _ProductA = CALCULATE( [ Your measure ], Table[Product] = "ProductA") RETURN IF( ISFILTERED(Table[Product]),[ Your measure ], _ProductA)
Effectively, you are checking if you are filtering for a product. If you are not filtering, then it will calculate your function for ProductA, else just return your measure. - 9 months ago
Hi maurcoll ,
You can create your required output by using if statement combined with the isfiltered function in your DAX measures. This allows the measure to check if the slicer has an active selection. If it doesn't, it defaults to "Product A".
You need to apply this logic to both your main value (TTM) and your target (PTTM).
KPI Value (Sales TTM) = VAR maxDate = TODAY() - DAY(TODAY()) VAR minDate = EDATE(TODAY() - DAY(TODAY()), -12) VAR SlicerIsFiltered = ISFILTERED('Product'[ProductName]) RETURN IF( SlicerIsFiltered, // Slicer is used: Calculate for selection CALCULATE( [Sales], 'Calendar'[Date] <= maxDate && 'Calendar'[Date] > minDate ), // Slicer is empty: Default to "Product A" CALCULATE( [Sales], 'Calendar'[Date] <= maxDate && 'Calendar'[Date] > minDate, 'Product'[ProductName] = "Product A" ) )KPI Target (Sales PTTM) = VAR current_maxDate = TODAY() - DAY(TODAY()) VAR current_minDate = EDATE(current_maxDate, -12) VAR prev_maxDate = current_minDate VAR prev_minDate = EDATE(current_minDate, -12) VAR SlicerIsFiltered = ISFILTERED('Product'[ProductName]) RETURN IF( SlicerIsFiltered, // Slicer is used CALCULATE( [Sales], 'Calendar'[Date] <= prev_maxDate && 'Calendar'[Date] > prev_minDate ), // Slicer is empty: Default to "Product A" CALCULATE( [Sales], 'Calendar'[Date] <= prev_maxDate && 'Calendar'[Date] > prev_minDate, 'Product'[ProductName] = "Product A" ) )You can use these two measures in your KPI visual's "Indicator" and "Target" fields.
The resultant output is as shown below:
I have attached an example pbix file for your reference.
Best regards,
Hello,
You can consider using the function ISFILTERED. So something like:
VAR _ProductA = CALCULATE( [ Your measure ], Table[Product] = "ProductA")
RETURN
IF(
ISFILTERED(Table[Product]),[ Your measure ], _ProductA)
Effectively, you are checking if you are filtering for a product. If you are not filtering, then it will calculate your function for ProductA, else just return your measure.