Forum Discussion
Anonymous
6 years agoNot applicable
Pie Chart behaviour without a legend (trying to simulate a legend without actually showing it)
Hello, I want to ask if it is actually possible to simulate the legend field behaviour in the default pie chart visual without actually adding a field in the legend.
The first 3 screenshots are how the "hacked" pie chart works now , as you can see in screenshot 3 : when i select a day of the week in 2018 it doesn't show the whole pie but only the day. However if i put the year field in the legend it works normally (screenshot 4).
The measure used in the donut is the following :
Number of Customers donut =
VAR maxYear =
CALCULATE ( MAX ( DimDate[Year] ), ALLSELECTED ( DimDate[Year] ) )
RETURN
IF (
HASONEFILTER ( DimDate[Year] ),
CALCULATE (
[Number of Customers],
FILTER (
ALL ( DimDate ),
DimDate[DayOfWeek] = VALUES ( DimDate[DayOfWeek] )
&& DimDate[Year] = VALUES ( DimDate[Year] )
&& DimDate[Week] = VALUES ( DimDate[Week] )
&& DimDate[DateKey] <= MAX ( DimDate[DateKey] )
)
),
CALCULATE (
[Number of Customers],
FILTER (
ALL ( DimDate ),
DimDate[DayOfWeek] = VALUES ( DimDate[DayOfWeek] )
&& DimDate[Year] = maxYear
&& DimDate[Week] = VALUES ( DimDate[Week] )
&& DimDate[DateKey] <= MAX ( DimDate[DateKey] )
)
)
)
VAR maxYear =
CALCULATE ( MAX ( DimDate[Year] ), ALLSELECTED ( DimDate[Year] ) )
RETURN
IF (
HASONEFILTER ( DimDate[Year] ),
CALCULATE (
[Number of Customers],
FILTER (
ALL ( DimDate ),
DimDate[DayOfWeek] = VALUES ( DimDate[DayOfWeek] )
&& DimDate[Year] = VALUES ( DimDate[Year] )
&& DimDate[Week] = VALUES ( DimDate[Week] )
&& DimDate[DateKey] <= MAX ( DimDate[DateKey] )
)
),
CALCULATE (
[Number of Customers],
FILTER (
ALL ( DimDate ),
DimDate[DayOfWeek] = VALUES ( DimDate[DayOfWeek] )
&& DimDate[Year] = maxYear
&& DimDate[Week] = VALUES ( DimDate[Week] )
&& DimDate[DateKey] <= MAX ( DimDate[DateKey] )
)
)
)
Also the year slicer used has 2 values selected : 2018 and 2019.
1 Reply
- AnonymousNot applicable
up