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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
liam_c
Frequent Visitor

Add new filter outside ALLEXCEPT

Hi, 

 

I am trying to calculate a 'share of trade' metric where the 'Total Market Sales' exists within my table. My example table looks like this:

I want to determine the following: 
Shop A's share of Total Market Sales for Category A. 

I currently have visual filters on the Category, Market, Time and State (I have another table called 'time type' that categorises FY or QTR).

 

liam_c_1-1621572046629.png

I have tried the following

Share of Trade = DIVIDE(SUM(DF[Sales]),CALCULATE(SUM(DF[Sales]),ALLEXCEPT(DF,DF[STATE],DF[Time],DF[Time_Type])&&DF[Market] = "Total Market"),0) . 
 
But this gives me no values. 
 
Any ideas? 
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @liam_c 

According to your description and sample data, I can roughly understand your requirement, I think you can try this measure:

 

Share of Trade =
VAR _TotalMarketSales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER (
            ALL ( 'Table' ),
            [Category] = MAX ( 'Table'[Category] )
                && [Market] = "Total Market"
        )
    )
RETURN
DIVIDE ( SUM ( 'Table'[Sales] ), _TotalMarketSales )

 

 

You can set the measure format to "Percentage" like this:

屏幕截图 2021-05-24 162433.png

 

Then you can create a table chart and place and set the visual like this to get your expected output:

v-robertq-msft_0-1621844580468.png

 

And you can get what you want.

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @liam_c 

According to your description and sample data, I can roughly understand your requirement, I think you can try this measure:

 

Share of Trade =
VAR _TotalMarketSales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER (
            ALL ( 'Table' ),
            [Category] = MAX ( 'Table'[Category] )
                && [Market] = "Total Market"
        )
    )
RETURN
DIVIDE ( SUM ( 'Table'[Sales] ), _TotalMarketSales )

 

 

You can set the measure format to "Percentage" like this:

屏幕截图 2021-05-24 162433.png

 

Then you can create a table chart and place and set the visual like this to get your expected output:

v-robertq-msft_0-1621844580468.png

 

And you can get what you want.

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

amitchandak
Super User
Super User

@liam_c , Try like

 

Share of Trade = DIVIDE(SUM(DF[Sales]),CALCULATE(SUM(DF[Sales]),Filter(allselected(DF),DF[STATE] = max(DF[STATE]) && DF[Time] = max(DF[Time]) && DF[Time_Type] = max(DF[Time_Type]) && DF[Market] = "Total Market")),0)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi, 

 

This still delivers 0.00% for all values 

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.