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

Show different Values (Average / SUM) in single bar graph based on selected slicer option

Dear Team,

 

I want to show the average of some values and sum of some values based upon the selected slicer option. Say for example, if we have a table A which has columns named products, months, country  and sales value. Products column had books and phones. If user selects books the value should be shown as average of Sales Value  column  keeping months, country constant (same as FIXED function in tableau) and if user selects phones sum of sales value should be shown keeping months, country constant.

Your support is appreciated.

thanks

1 ACCEPTED SOLUTION

Hi, @Aishu_2609

Books and phones are the contents of the "Products" field where I group them in the formula.

If the results are incorrect, please share sample data and expected results for further research.

Best Regards,
Community Support Team _ Eason

View solution in original post

4 REPLIES 4
Aishu_2609
New Member

@v-easonf-msft Manny thanks for this , can you kindly confirm if I can use Msales as a slicer and slicer will show books and phones as 2 options to select?

Hi, @Aishu_2609

Books and phones are the contents of the "Products" field where I group them in the formula.

If the results are incorrect, please share sample data and expected results for further research.

Best Regards,
Community Support Team _ Eason

Many Thanks 

v-easonf-msft
Community Support
Community Support

Hi,  @Aishu_2609 

Please try measure like blow:

 

M_Sales =
SWITCH (
    SELECTEDVALUE ( 'Table'[Products] ),
    "Books",
        CALCULATE (
            AVERAGE ( 'Table'[sales] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[country] = MAX ( 'Table'[country] )
                    && 'Table'[Products] = MAX ( 'Table'[Products] )
            )
        ),
    "Phones",
        CALCULATE (
            SUM ( 'Table'[sales] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[country] = MAX ( 'Table'[country] )
                    && 'Table'[Products] = MAX ( 'Table'[Products] )
            )
        )
)

 

Best Regards,
Community Support Team _ Eason

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.