Daily DAX : Day 192 NONVISUAL
The NONVISUAL DAX function in Power BI is used to mark a calculation or measure as non-visual, meaning it will not be displayed in visuals like tables, charts, or matrices, but can still be used in calculations or as part of other measures. It is primarily used in scenarios where you want to compute intermediate values or aggregations that support other calculations without cluttering the visual output.
Syntax
dax
NONVISUAL(<expression>)
expression: The DAX expression or measure you want to mark as non-visual.
How It Works
The NONVISUAL function wraps an expression or measure, ensuring it is excluded from being directly displayed in visuals.
The result of the expression is still calculated and can be referenced in other measures or calculations.
It is particularly useful in complex models where intermediate calculations are needed but should not appear in reports.
Use Cases
Intermediate Calculations:
When you need to compute a value (e.g., a subtotal or a ratio) that is used in other measures but shouldn’t be shown in visuals.
Example: Calculate a weighted average or a temporary aggregation that feeds into a final measure.
Conditional Logic:
Use NONVISUAL to create helper measures that drive conditional logic or filtering without displaying the helper measure in reports.
Example: A measure that flags certain conditions (e.g., sales above a threshold) for use in other calculations.
Optimizing Report Clarity:
Prevents users from accidentally including irrelevant or intermediate calculations in visuals, keeping reports clean and focused.
Example
Suppose you have a measure to calculate total sales and want to create an intermediate measure for sales in a specific region that should not appear in visuals but is used in other calculations.
dax
RegionSales =
CALCULATE(
SUM(Sales[Amount]),
Sales[Region] = "North"
)
To ensure RegionSales is not displayed in visuals, wrap it with NONVISUAL:
dax
NonVisualRegionSales =
NONVISUAL(
CALCULATE(
SUM(Sales[Amount]),
Sales[Region] = "North"
)
)
Now, NonVisualRegionSales can be used in other measures, such as calculating the percentage of total sales:
dax
RegionSalesPercentage =
DIVIDE(
[NonVisualRegionSales],
SUM(Sales[Amount]),
0
)
In this case:
NonVisualRegionSales won’t appear in visuals like tables or charts.
It can still be referenced in the RegionSalesPercentage measure.
Key Notes
NONVISUAL does not affect the calculation logic or performance; it only controls visibility in visuals.
It is often used in combination with other DAX functions like CALCULATE, SUM, or DIVIDE for intermediate steps.
If a measure marked as NONVISUAL is accidentally included in a visual, it will not render, avoiding confusion.
Limitations
NONVISUAL only applies to measures, not calculated columns or tables.
It does not hide the measure from the field list in Power BI; it only prevents rendering in visuals. To hide it completely from users, you may need to use the "Hide" option in the model.
Practical Tip
Use NONVISUAL in large models with many measures to improve user experience by reducing visual clutter and ensuring only relevant metrics are shown in reports.
Comments
Post a Comment