Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Solved! Go to Solution.
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.
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.
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.
@Ritaf1983 , Thank you.
Is there any way that we can do this without repetitively creating the same measures? Looking for some optimal solution.
Hi @Arul
It would be difficult to do this without creating multiple measures.
I suggest you create different measures for different visuals.
If you find another way, look forward to your sharing!
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Arul
Check the solution that @Anonymous suggested....
User | Count |
---|---|
73 | |
70 | |
38 | |
25 | |
23 |
User | Count |
---|---|
96 | |
93 | |
50 | |
43 | |
42 |