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 need to apply conditional formating in BI -as per shown in below image
location wise month wise (each row wise ) highest & lowest value .
highest value for each location & each month should be green.
i have tried calcuation using summarize coulms but its not working . please help with the dax
Refrence snapshot for problem statement
Thanks in Advance.
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
Sales measure: =
SUM(Sales[Sales])
INDEX function (DAX) - DAX | Microsoft Learn
Color format measure: =
VAR _sales = [Sales measure:]
VAR _hightest =
CALCULATE (
[Sales measure:],
INDEX (
1,
ALL ( 'Calendar'[Month-Year sort], 'Calendar'[Month-Year] ),
ORDERBY ( [Sales measure:], DESC )
)
)
VAR _lowest =
CALCULATE (
[Sales measure:],
INDEX (
1,
ALL ( 'Calendar'[Month-Year sort], 'Calendar'[Month-Year] ),
ORDERBY ( [Sales measure:], ASC )
)
)
RETURN
SWITCH ( TRUE (), _sales = _hightest, "green", _sales = _lowest, "red" )
Hi,
Please check the below picture and the attached pbix file.
Sales measure: =
SUM(Sales[Sales])
INDEX function (DAX) - DAX | Microsoft Learn
Color format measure: =
VAR _sales = [Sales measure:]
VAR _hightest =
CALCULATE (
[Sales measure:],
INDEX (
1,
ALL ( 'Calendar'[Month-Year sort], 'Calendar'[Month-Year] ),
ORDERBY ( [Sales measure:], DESC )
)
)
VAR _lowest =
CALCULATE (
[Sales measure:],
INDEX (
1,
ALL ( 'Calendar'[Month-Year sort], 'Calendar'[Month-Year] ),
ORDERBY ( [Sales measure:], ASC )
)
)
RETURN
SWITCH ( TRUE (), _sales = _hightest, "green", _sales = _lowest, "red" )
To apply conditional formatting in Power BI to highlight the highest and lowest values for each location and each month, you can follow these steps:
Here's how you can achieve this using DAX:
You need to create a calculated column that checks if the current value is the highest or lowest for the respective location and month.
MaxValue =
VAR CurrentLocation = 'YourTable'[Location]
VAR CurrentMonth = SELECTEDVALUE('YourTable'[Month])
RETURN
IF(
'YourTable'[Value] = CALCULATE(MAX('YourTable'[Value]), ALLEXCEPT('YourTable', 'YourTable'[Location], 'YourTable'[Month])),
"Max",
IF(
'YourTable'[Value] = CALCULATE(MIN('YourTable'[Value]), ALLEXCEPT('YourTable', 'YourTable'[Location], 'YourTable'[Month])),
"Min",
BLANK()
)
)
Replace 'YourTable' with the name of your table, and 'Value' with the name of the column that contains your numerical values.
Apply Conditional Formatting:
This setup will highlight the highest and lowest values for each location and month in your Power BI report. Make sure you adjust column names and table names according to your data model.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
8 | |
6 |