Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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])?
Solved! Go to Solution.
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
Proud to be a Datanaut!
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
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:
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
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
Proud to be a Datanaut!
User | Count |
---|---|
125 | |
106 | |
99 | |
63 | |
62 |
User | Count |
---|---|
135 | |
116 | |
101 | |
71 | |
61 |