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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
FCF
Helper IV
Helper IV

using # of selected items in a slicer as a calculation

Hi everyone.

here is the situtation. I have a table that  displays the total # of stems counted, 

it also includes the croparea, or the amount of space each plant resides 

 

I calculate the number of stems per sq meter using the following formula,

Total Stems/ crop area

example      8519/143= 59.57  

these caluclation work fine, the issue is when you view more then one  crop at a time.

I use a slicer called crop to filter the table, I have select 2 crop types, Amuse and Bison 

 

Amuse has 8519 stems, and a crop area of 143sqm

Bison has 7254 stems, and a crop area of 143sqm

 

Amuse 8519 / 143 = 59.57

Bison   7458 / 143 = 52.19

 

combine values

 

stems  =     15623 

crop area = 286

15623 / 286 = 54.625 stems per sq meter

 

the results do not calculate properly in the table

 it adds the stems properly to 15623, and the crop area of 286 but sum the stems per meter giving a total of 111.73. this is not correct

 

table.JPG

 

 
 
 

 

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @FCF ,

You can refer to this post:

Power BI (DAX) – Quick Tip – How to count how many items are selected on a Slicer.

 

I create an example.

Sum = SUM('Table'[Sales])
Product Slicer Count =
CALCULATE (
    COUNTROWS ( FILTERS ( 'Table'[Product] ) ),
    ALLSELECTED ( 'Table' )
)
Average = DIVIDE([Sum],[Product Slicer Count])

slicer.gif

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Icey
Community Support
Community Support

Hi @FCF ,

You can refer to this post:

Power BI (DAX) – Quick Tip – How to count how many items are selected on a Slicer.

 

I create an example.

Sum = SUM('Table'[Sales])
Product Slicer Count =
CALCULATE (
    COUNTROWS ( FILTERS ( 'Table'[Product] ) ),
    ALLSELECTED ( 'Table' )
)
Average = DIVIDE([Sum],[Product Slicer Count])

slicer.gif

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

FCF
Helper IV
Helper IV

hi

is there not a way to count the # of items selected in a slicer. ????

amitchandak
Super User
Super User

Your formula should be like

Formula = divide(sum(Total Stems),sum(crop area))

Not like

Formula = sumx(table,Total Stems/crop area)

 

Means, first aggregate and then divide

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Hi thanks for your suggestion, but when i use the following 

TotalActual = Divide(sum([total]);syn([croparea]) 

i get an incorrect result.

i want the results to  be divided by the number of crops selected in the slicer, in this instance it is 2

regards

Ideally the selected values should filter, if the tables are joined.

Check that filter is passing to that region.

 

Interactions.png

 

It should one ot the two bar graphs(icon). when you select slicer.

hi

thanks for the reply, but i am using a basic slicer slicer.JPG

I want to count the # of items selected in the slicer, in this example it is 2

Regards

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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