March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi!
I tried to add min and max label at the column chart by used following measure:
When i drill down to quarter and day it also looks fine, but I when I drill down to month each data labes are equal "Min"
I created my own hierarchy by:
Solved! Go to Solution.
The problem is the month section. When you set the sort by column to month number that means that the month number is added to the underlying DAX query even though it isn't visible in the chart. So when the month is in scope the month number is also in scope, and although you are effectively removing the filter on month by using ALL, the filter on month number remains.
You need to remove the filters on month number and then it will work again. Change the lines for the month section to
NOT ISINSCOPE ( 'Table'[day] ) && ISINSCOPE ( 'Table'[Month] )
&& CurrentAvg = CALCULATE ( MINX ( ALL ( 'Table'[Month] ), [AvgPrice] ), REMOVEFILTERS( 'Table'[Month number]) ), "Min",
NOT ISINSCOPE ( 'Table'[day] ) && ISINSCOPE ( 'Table'[Month] )
&& CurrentAvg = CALCULATE ( MAXX ( ALL ( 'Table'[Month] ), [AvgPrice] ), REMOVEFILTERS( 'Table'[Month number]) ), "Max",
Swap the sections for month and quarter around so that the order of the SWITCH statement is day, month, quarter, year.
Unfortunately it still doesn't work
Hi, @Retine18
Based on your inforamtion, I create a sample table:
Then create hierarchy columns and new measure:
Test = SWITCH(
TRUE(),
ISINSCOPE('Table'[day]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[day]), [AvgPrice])), "Min",
ISINSCOPE('Table'[day]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[day]), [AvgPrice])), "Max",
ISINSCOPE('Table'[Month]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[Month]), [AvgPrice])), "Min",
ISINSCOPE('Table'[Month]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[Month]), [AvgPrice])), "Max",
ISINSCOPE('Table'[quater]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[quater]), [AvgPrice])), "Min",
ISINSCOPE('Table'[quater]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[quater]), [AvgPrice])), "Max",
ISINSCOPE('Table'[year]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[year]), [AvgPrice])), "Min",
ISINSCOPE('Table'[year]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[year]), [AvgPrice])), "Max",
BLANK()
)
Put them in column chart and put measure in laber format:
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
At Yours file I added the same scenario that I have in my file. I had the same problem:
You had the sections in the reverse order
This will work
Test2 = SWITCH(
TRUE(),
ISINSCOPE('Table'[day]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[day]), [AvgPrice])), "Min",
ISINSCOPE('Table'[day]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[day]), [AvgPrice])), "Max",
ISINSCOPE('Table'[Month]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[Month]), [AvgPrice])), "Min",
ISINSCOPE('Table'[Month]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[Month]), [AvgPrice])), "Max",
ISINSCOPE('Table'[quater]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[quater]), [AvgPrice])), "Min",
ISINSCOPE('Table'[quater]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[quater]), [AvgPrice])), "Max",
ISINSCOPE('Table'[year]) && [AvgPrice] = CALCULATE(MINX(ALL('Table'[year]), [AvgPrice])), "Min",
ISINSCOPE('Table'[year]) && [AvgPrice] = CALCULATE(MAXX(ALL('Table'[year]), [AvgPrice])), "Max",
BLANK()
)
Ok, I changed it and it works as expected when you went at the next in the hierarchy, but when you drilled down by clicked a datapoint to drill, recived as follow:
But that screenshot is still showing the wrong measure definition.
So sorry, added wrong screenshow.
I understand the problem. The code also needs to check that the lower levels of the hierarchy are not also in scope, as e.g. year is in scope at all levels of the hierarchy.
Test2 = VAR CurrentAvg = [AvgPrice]
RETURN
SWITCH (
TRUE (),
ISINSCOPE ( 'Table'[day] )
&& CurrentAvg = CALCULATE ( MINX ( ALL ( 'Table'[day] ), [AvgPrice] ) ), "Min",
ISINSCOPE ( 'Table'[day] )
&& CurrentAvg = CALCULATE ( MAXX ( ALL ( 'Table'[day] ), [AvgPrice] ) ), "Max",
NOT ISINSCOPE ( 'Table'[day] ) && ISINSCOPE ( 'Table'[Month] )
&& CurrentAvg = CALCULATE ( MINX ( ALL ( 'Table'[Month] ), [AvgPrice] ) ), "Min",
NOT ISINSCOPE ( 'Table'[day] ) && ISINSCOPE ( 'Table'[Month] )
&& CurrentAvg = CALCULATE ( MAXX ( ALL ( 'Table'[Month] ), [AvgPrice] ) ), "Max",
NOT ISINSCOPE ( 'Table'[day] )
&& NOT ISINSCOPE ( 'Table'[Month] ) && ISINSCOPE ( 'Table'[quater] )
&& CurrentAvg = CALCULATE ( MINX ( ALL ( 'Table'[quater] ), [AvgPrice] ) ), "Min",
NOT ISINSCOPE ( 'Table'[day] )
&& NOT ISINSCOPE ( 'Table'[Month] ) && ISINSCOPE ( 'Table'[quater] )
&& CurrentAvg = CALCULATE ( MAXX ( ALL ( 'Table'[quater] ), [AvgPrice] ) ), "Max",
NOT ISINSCOPE ( 'Table'[day] )
&& NOT ISINSCOPE ( 'Table'[Month] )
&& NOT ISINSCOPE ( 'Table'[quater] ) && ISINSCOPE ( 'Table'[year] )
&& CurrentAvg = CALCULATE ( MINX ( ALL ( 'Table'[year] ), [AvgPrice] ) ), "Min",
NOT ISINSCOPE ( 'Table'[day] )
&& NOT ISINSCOPE ( 'Table'[Month] )
&& NOT ISINSCOPE ( 'Table'[quater] ) && ISINSCOPE ( 'Table'[year] )
&& CurrentAvg = CALCULATE ( MAXX ( ALL ( 'Table'[year] ), [AvgPrice] ) ), "Max",
BLANK ()
)
I've also replaced the individual calculations of the [AvgPrice] with a variable so that it is only calculated once for the current granularity.
Thank you it works! 🙂 But when i added column month nr=MONTH('Table'[date]) and sorted month columny by month nr received the same problem as previous. Do you have any idea why and how fix it without delete month nr column?
The problem is the month section. When you set the sort by column to month number that means that the month number is added to the underlying DAX query even though it isn't visible in the chart. So when the month is in scope the month number is also in scope, and although you are effectively removing the filter on month by using ALL, the filter on month number remains.
You need to remove the filters on month number and then it will work again. Change the lines for the month section to
NOT ISINSCOPE ( 'Table'[day] ) && ISINSCOPE ( 'Table'[Month] )
&& CurrentAvg = CALCULATE ( MINX ( ALL ( 'Table'[Month] ), [AvgPrice] ), REMOVEFILTERS( 'Table'[Month number]) ), "Min",
NOT ISINSCOPE ( 'Table'[day] ) && ISINSCOPE ( 'Table'[Month] )
&& CurrentAvg = CALCULATE ( MAXX ( ALL ( 'Table'[Month] ), [AvgPrice] ), REMOVEFILTERS( 'Table'[Month number]) ), "Max",
Thank you very much for solution and explanation! 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
133 | |
91 | |
88 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
73 | |
68 |