Forum Discussion
Hide Visual Metrics based on Config file
Hi all,
I have config file which is having below data,
| ID | Metric Name | Flag | Visual |
| 1 | Sales | 1 | V1 |
| 2 | Profit | 1 | V1 |
| 3 | Gross Sales | 1 | V1 |
| 4 | Sales | 0 | V2 |
| 5 | Profit | 1 | V2 |
| 6 | Gross Sales | 1 | V2 |
I have below visuals in Power BI, My requirement is to hide certain metrics in visual 1 but to show the same metrics in visual 2 based on the config file. Could anyone have any idea to achieve this? I am doing it based on measures right now.
- Anonymous1 year ago
Hi Arul
Thank you very much Ritaf1983 for your prompt reply. Let me share a few things here.
Here I assume that your sales sheet looks like this:
“Sales”
Based on the data you provide, I recommend that you create measures for both visual objects separately.
Measure V1 = CALCULATE( SUM('Sales'[Value]), FILTER( 'Config', 'Config'[Visual] = "V1" && 'Config'[Metric Name] = SELECTEDVALUE('Sales'[Name]) && 'Config'[Flag] <> 0 ))Measure V2 = CALCULATE( SUM('Sales'[Value]), FILTER( 'Config', 'Config'[Visual] = "V2" && 'Config'[Metric Name] = SELECTEDVALUE('Sales'[Name]) && 'Config'[Flag] <> 0 ))Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 Replies
- AnonymousNot applicable
Hi Arul
Thank you very much Ritaf1983 for your prompt reply. Let me share a few things here.
Here I assume that your sales sheet looks like this:
“Sales”
Based on the data you provide, I recommend that you create measures for both visual objects separately.
Measure V1 = CALCULATE( SUM('Sales'[Value]), FILTER( 'Config', 'Config'[Visual] = "V1" && 'Config'[Metric Name] = SELECTEDVALUE('Sales'[Name]) && 'Config'[Flag] <> 0 ))Measure V2 = CALCULATE( SUM('Sales'[Value]), FILTER( 'Config', 'Config'[Visual] = "V2" && 'Config'[Metric Name] = SELECTEDVALUE('Sales'[Name]) && 'Config'[Flag] <> 0 ))Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Ritaf1983Super User
Hi Arul
If I understood correctly, the table you shared has flags indicating whether a metric should be shown or hidden in each visual. To achieve your requirement, you'll need to create separate measures for each visual, using the flags in the config file to determine which metrics to display.
Since the Power BI engine doesn’t inherently know which visual it's dealing with, there’s no direct way to toggle visibility of metrics based on visuals. Instead, you can set up specific measures that check the flags for each visual and display only the relevant metrics.
For example:
1. Create a measure for Visual 1 that only includes metrics where the flag is 1 for V1.
2. Create a measure for Visual 2 that includes metrics based on the flag for V2.
Each measure will reference the appropriate flags and determine which data to display, ensuring that Visual 1 and Visual 2 show the intended metrics.If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.