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
hamoso
New Member

Create aggregate (AVG, MIN, MAX, SUM, ...) Slicer

Hi guys,

 

I couldn't find the answer using the search functionality. Therefore I wanted to ask you guys if you could help me with this case.

 

I have created a matrix table which shows the average occupation levels for different vehicles.

Matrix table.png

 

I would now like to create a slicer to select whether the minimum, maximum, average or totalized occupation levels are displayed. You can do this by right-clicking in the values field (see picture below), but I would like to have a slicer in the dashboard so that a customer can also filter between the aggregates, for example.

 

Screenshot 2024-04-10 160154.png

 

Does anyone have a solution for this? I would be grateful for any suggestions.

 

Yours faithfully

Homoso

 

1 ACCEPTED SOLUTION
v-zhouwen-msft
Community Support
Community Support

Hi @hamoso ,

The Table data is shown below:

vzhouwenmsft_0-1713404448930.png

Please follow these steps:

1.Create a table and enter the following data manually.

vzhouwenmsft_1-1713404526428.png

vzhouwenmsft_2-1713404547450.png

2.Use the following DAX expression to create a measure

 

Measure = 
VAR _a = SELECTEDVALUE('Table 2'[Type])
VAR _b = IF(_a = "Sum",SUM('Table'[Value]),
            IF(_a = "Average",AVERAGE('Table'[Value]),
                IF(_a = "Minimum",MIN('Table'[Value]),
                    IF(_a = "Maximum",MAX('Table'[Value]),
                        IF(_a = "Count",COUNT('Table'[Value]))))))
RETURN _b

 

3.Final output

vzhouwenmsft_3-1713404650006.png

vzhouwenmsft_4-1713404671982.png

vzhouwenmsft_5-1713404686476.png

vzhouwenmsft_6-1713404703975.png

vzhouwenmsft_7-1713404717758.png

vzhouwenmsft_8-1713404741717.png

 

Best Regards,
Wenbin Zhou
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

5 REPLIES 5
v-zhouwen-msft
Community Support
Community Support

Hi @hamoso ,

The Table data is shown below:

vzhouwenmsft_0-1713404448930.png

Please follow these steps:

1.Create a table and enter the following data manually.

vzhouwenmsft_1-1713404526428.png

vzhouwenmsft_2-1713404547450.png

2.Use the following DAX expression to create a measure

 

Measure = 
VAR _a = SELECTEDVALUE('Table 2'[Type])
VAR _b = IF(_a = "Sum",SUM('Table'[Value]),
            IF(_a = "Average",AVERAGE('Table'[Value]),
                IF(_a = "Minimum",MIN('Table'[Value]),
                    IF(_a = "Maximum",MAX('Table'[Value]),
                        IF(_a = "Count",COUNT('Table'[Value]))))))
RETURN _b

 

3.Final output

vzhouwenmsft_3-1713404650006.png

vzhouwenmsft_4-1713404671982.png

vzhouwenmsft_5-1713404686476.png

vzhouwenmsft_6-1713404703975.png

vzhouwenmsft_7-1713404717758.png

vzhouwenmsft_8-1713404741717.png

 

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

Hi @v-zhouwen-msft ,

 

you are the best! Thank you for your help. This was excactly what I was looking for. 🙂

Wilson_
Memorable Member
Memorable Member

Hi hamoso,

 

Look into calculation groups. Here is a potential resource for you; they talk about using an external tool but calculation groups were recently introduced in Power BI as a native functionality I believe.


----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

 

P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.

Hi @Wilson_ ,

 

thank you for your suggestion.  @v-zhouwen-msft 's solution was easier to implement, so I opted for this one. Nevertheless, thanks again for your suggestion.

hamoso,

 

No worries, calculation groups are more robust if you're looking to scale the ability to do what you're trying to do. Understandable to go a different direction if you're just trying to do it one time. Glad you got something that works for you. 😄

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.