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.
I have a bar chart that shows a distribution. I would like to create a measure that returns one color for bars that fall within a certain value.
If my distribution is from 0-1, I would like to have a measure that colors the bar falling between 0.1 and 0.2 a different color, but this range should be dynamic based on a user selection in a slicer, so it can't be hard coded in a rule, must be a field.
Is this possible? Currently, I have not thought of a way as you need to wrap in an iterator to be able to refernce the specific value in a column (x axis is created using generateseries), and this will just return the first value comparission:
sumx(distribution, var currentrow = distribution[values]
return if(currentrow = 0.1, color 1, color 2))
will just return color 2 unless the value is 0.1. Does that make sense?
Thank you.
Solved! Go to Solution.
I would like to apologize for the belated reply.
My sample:
I've modified the formula.
color =
IF (
SELECTEDVALUE ( slicer[distribution] ) = BLANK (),
"blue",
IF (
SELECTEDVALUE ( 'Table'[distribution] ) + 0.1
= SELECTEDVALUE ( slicer[distribution] )
|| SELECTEDVALUE ( 'Table'[distribution] ) - 0.1
= SELECTEDVALUE ( slicer[distribution] ),
"yellow",
"blue"
)
)
Is this the result you expect?
If I've misunderstood you, please provide detailed sample data and the results you are hoping for:
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Please remove any sensitive data in advance.
Best Regards,
Community Support Team _Yuliax
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can try the following steps.
1. Create a measure as follows.
Measure = IF(SELECTEDVALUE('Table'[distribution]) >= 0.1 && SELECTEDVALUE('Table'[distribution]) <= 0.2, "yellow", "blue")
2. With this clustered bar chart selected, I did what is shown here.
Is this the result you expect?
Best Regards,
Community Support Team _Yuliax
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you very much for this explanation @Anonymous . I apologize as I was too vague with my inquiry. In the end, this should be based on a unique identifier for a store.
The histogram is created with a 0 - 1 distribution on the x axis while the y axis is a countx of stores. I thought innitially that one could highlight based on selectedvalue of the store, but there is no identifying information in the countx.
This 0-1 distribution is based on a metric, such as % of sales a store contributes to a certain product. So my idea was instead of going off store ID, I could go off the metric itself, and highlight based on x axis instead of y axis. So I fetch the value for the metric in a measure for the selected store, then if it is within +- 0.01 of that selected stores metric, that column is highlighted.
I will try the code you wrote, but it seems like this is hard coded for 0.1 and 0.2, and would only color if the user selects something in that range. Really, I want the user selection to be the thing that is colored. So even if we ignore the extra layer of the stores, is is possible to have a measure that takes selectedvalue of slicer from 0-1 and highlight the bars in that range? So user selects a value of 0.3, the bar with x axis value 0.3 is selected.
I would like to apologize for the belated reply.
My sample:
I've modified the formula.
color =
IF (
SELECTEDVALUE ( slicer[distribution] ) = BLANK (),
"blue",
IF (
SELECTEDVALUE ( 'Table'[distribution] ) + 0.1
= SELECTEDVALUE ( slicer[distribution] )
|| SELECTEDVALUE ( 'Table'[distribution] ) - 0.1
= SELECTEDVALUE ( slicer[distribution] ),
"yellow",
"blue"
)
)
Is this the result you expect?
If I've misunderstood you, please provide detailed sample data and the results you are hoping for:
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Please remove any sensitive data in advance.
Best Regards,
Community Support Team _Yuliax
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
72 | |
38 | |
31 | |
26 |