Become a Dynamics 365 expert with Syvantis Learn
Provide additional details about the offer you're running.
This store requires javascript to be enabled for some features to work correctly.
Provide additional details about the offer you're running.
How to use scope with measures in Power BI
Power BI & Fabric • Power Platform
Learn how the IsInScope and SelectedValue functions in Power BI can give you more control over how measures are calculated and displayed. This Fast Class covers practical ways to adjust calculations at different levels of a visual, simplify complex matrices, apply dynamic formatting, and give report users more control over how information is displayed.
Power BI calculates values according to the context, or scope, of each part of a visual. For example, a sales matrix might begin at the location level and then let you drill down to salesperson and product. Each level introduces different information into the calculation.
IsInScope and SelectedValue let you identify that context and use it within your measures. This can be especially useful when you want calculations or formatting to behave differently depending on where users are within a report.
Using IsInScope
The IsInScope function returns True or False depending on whether a specified column is currently within the scope of a measure. For example, in a matrix containing location, salesperson, product, and date information, IsInScope can identify which fields are contributing to a calculation as you drill through the hierarchy.
This can be useful for troubleshooting calculations because you can check which fields are in scope at the point where unexpected results occur. It can also be used to change calculations at different levels of a visual.
Changing calculations based on scope
One practical use for IsInScope is simplifying a matrix that would otherwise require several value columns. For example, you might want to display:
Instead of showing separate columns for each calculation, you can create a combined measure. Using a SWITCH statement with IsInScope, the measure can determine the current level of the hierarchy and return the appropriate calculation. Because the SWITCH statement returns the first true condition, start with the lowest level of the hierarchy and work upward. In this example, that means checking the product level first, followed by salesperson and location.
Using dynamic formatting
Once calculations have been combined into a single measure, it may not be obvious what each number represents. Dynamic formatting can provide that context. Using the same scope logic, you can apply formatting that identifies product-level values as “Items Sold” while identifying salesperson- and location-level values as “Sales Made.” This lets you reduce unnecessary columns while still making the results understandable to report users.
Using SelectedValue
SelectedValue returns the actual value of a field within the current scope rather than simply telling you whether the field is in scope. For example, a calculation could identify a specific location such as Detroit. As you drill further into the matrix, SelectedValue can also identify values such as the salesperson or product used in that calculation. This gives you another way to customize calculations and report behavior based on the user's current selection.
Applying conditional formatting with SelectedValue
SelectedValue can also be used to control report formatting. In the example from this Fast Class, each sales location has an associated color. A measure uses SelectedValue to determine the current location and a SWITCH statement to return the appropriate color. That measure can then be used for conditional formatting so the font colors in the matrix correspond with the colors used elsewhere in the report.
Giving users control with a slicer
SelectedValue can also work with a control table to let report users choose how information is displayed. For example, you can create a table containing two options:
Add those options to a single-selection slicer and update the formatting measure to check the selected option. If Show colors is selected, the measure returns the location-specific colors. Otherwise, it returns the default text color. The same approach can be extended beyond colors. SelectedValue and control tables can be used to change calculations, report settings, or conversions such as switching between miles and kilometers.
Key takeaways
IsInScope helps determine which fields are currently included in the scope of a calculation. You can use that information to troubleshoot visuals or change how measures behave at different levels of a report. SelectedValue returns the specific value within the current context.
This allows you to fine-tune calculations, apply conditional formatting, and create slicers that give users more control over their report experience.
* This transcript summary has been generated from the Fast Class video by Microsoft Copilot. The Fast Class itself was prepared and taught by Syvantis expert consultants.
TUNE INTO THE LIVE CLASS
Ask your questions and get real-time responses from your trusted Syvantis consultants.
What's on the schedule?
Dynamics 365 Business Central
Dynamics 365 Sales (CRM)
Dynamics 365 Customer Insights
Power Platform
Keep learning...
Business Process Designers. Technical Experts. Dedicated Partners.