Forum Discussion
Interaction between line chart and pie chart
- Anonymous3 years ago
Hi mvega07 ,
You can add filters to the code instead of the visual filters. Try using this MEASURE in the pie chart.
Current Month Sales = CALCULATE ( SUM ( 'FactSalesTable'[Sales] ), 'Calendar'[Year] = YEAR ( TODAY () ) && 'Calendar'[Month Number] = MONTH ( TODAY () ) )If the current month refers to the month and year of the largest date in the date table, you can use this variable instead of TODAY().
VAR _max_date = CALCULATE(MAX('Calendar'[Date]),ALL())For the line chart, you can add a column to the date table.
then add a visual filter.
result:
Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi mvega07 ,
You can add filters to the code instead of the visual filters. Try using this MEASURE in the pie chart.
Current Month Sales =
CALCULATE (
SUM ( 'FactSalesTable'[Sales] ),
'Calendar'[Year] = YEAR ( TODAY () )
&& 'Calendar'[Month Number] = MONTH ( TODAY () )
)
If the current month refers to the month and year of the largest date in the date table, you can use this variable instead of TODAY().
VAR _max_date = CALCULATE(MAX('Calendar'[Date]),ALL())
For the line chart, you can add a column to the date table.
then add a visual filter.
result:
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
- mvega073 years agoFrequent Visitor
Thanks, this works. The only thing is that when I then click on a specific data point in the line graph, the pie chart dissappears instead of showing how the sales per country where on the selected date. Do I have to modify the measure somehow to reflect this?
- mvega073 years agoFrequent Visitor
Actually, just solved it. Updated my measure to this:
Current sales = VAR max_date = CALCULATE(MAX(Table_example[Date]),ALL()) RETURN CALCULATE(SUM(Table_example[Sales]),FILTER(Table_example,Table_example[Date]=SELECTEDVALUE(Table_example[Date],max_date)) )