cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

How to use the treemap to change what is shown on another graph

I have a treemap at the top of my dashboard and using it to filter the rest of the dashboard (it contains Product names). I have a line chart underneath which plots Sales over time. I was wondering if there was a way that if one product is selected from the treemap, the line graph shows SUM([Sales]) but if more than one product or all products are clicked on the treemap it shows AVERAGE([Sales])?

1 ACCEPTED SOLUTION
Super User II
Super User II

Hi @RickmasPick ,

 

I may be oversimplifying your requirement here, but would a measure like this work?

_chartSales =
IF(
  HASONEVALUE([ProductName]),
  SUM([Sales]),
  AVERAGE([Sales])
)

 

Pete

View solution in original post

3 REPLIES 3
Microsoft
Microsoft

Hi @RickmasPick ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,
Eyelyn Qin

Microsoft
Microsoft

Hi @RickmasPick ,

 

Sorry for my late reply...

 

According to my understand, if more than one product is selected , then show the average of their values ,otherwise show the sum of the seleced , right?

 

You could use the following formula:

Measure =
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Product Names] ),
        FILTER (
            'Table',
            'Table'[Product Names] IN ALLSELECTED ( 'Table'[Product Names] )
        )
    )
RETURN
    IF ( _count <= 1, SUM ( 'Table'[Value] ), SUM ( 'Table'[Value] ) / _count )

 My final output looks like this:

12.1.4.1.gif

 

Here is the pbix file.

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

Super User II
Super User II

Hi @RickmasPick ,

 

I may be oversimplifying your requirement here, but would a measure like this work?

_chartSales =
IF(
  HASONEVALUE([ProductName]),
  SUM([Sales]),
  AVERAGE([Sales])
)

 

Pete

View solution in original post

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors