Forum Discussion
okokokokok
1 year agoRegular Visitor
Bar chart legend drill down
Hello community, What I am trying to do is fairly simple, but seem to find a way. This is my current graph: On the X axis, I have dates On the Y axis, I have a count For the legend, I ...
- 1 year ago
Hi okokokokok ,
Since you are using the country and continent on the legend there is no drill down option and you need to have a single column for your legend I would do the following:
- Create a new table with a list of all continents and countries
- Add a column with the type for each one
- Add the following measure:
Total Value = VAR _country = SELECTCOLUMNS( FILTER( 'Continent/Country', 'Continent/Country'[Type] = "Country" ), "Country", 'Continent/Country'[value] ) VAR _continent = SELECTCOLUMNS( FILTER( 'Continent/Country', 'Continent/Country'[Type] = "Continent" ), "Continent", 'Continent/Country'[value] ) RETURN IF( DISTINCTCOUNT('Fact'[Continent]) = 1, COUNTROWS( FILTER( 'Fact', 'Fact'[Country] IN _country ) ), COUNTROWS( FILTER( 'Fact', 'Fact'[Continent] IN _continent ) ) )- Format the visual like this:
- X-axis - Date
- Y-Axis - Total Value measure
- Legend - Value from the new table
Check the result below and in attach file:
MFelix
Super User
1 year agoHi okokokokok ,
Since you are using the country and continent on the legend there is no drill down option and you need to have a single column for your legend I would do the following:
- Create a new table with a list of all continents and countries
- Add a column with the type for each one
- Add the following measure:
Total Value =
VAR _country = SELECTCOLUMNS(
FILTER(
'Continent/Country',
'Continent/Country'[Type] = "Country"
),
"Country", 'Continent/Country'[value]
)
VAR _continent = SELECTCOLUMNS(
FILTER(
'Continent/Country',
'Continent/Country'[Type] = "Continent"
),
"Continent", 'Continent/Country'[value]
)
RETURN
IF(
DISTINCTCOUNT('Fact'[Continent]) = 1,
COUNTROWS(
FILTER(
'Fact',
'Fact'[Country] IN _country
)
),
COUNTROWS(
FILTER(
'Fact',
'Fact'[Continent] IN _continent
)
)
)
- Format the visual like this:
- X-axis - Date
- Y-Axis - Total Value measure
- Legend - Value from the new table
Check the result below and in attach file: