Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

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

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

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

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

v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

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

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

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

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

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.