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
woombers
Frequent Visitor

% share of revenue calculation filter issue

Hi there

 

Struggling to figure out how to apply filters on this use-case. My goal is to populate the "% share of revenue" columns in the Cost of Materials and Personnel Costs columns below.

 

 Revenue Cost of Materials Personnel costs 
ProductValue% share of RevenueValue% share of RevenueValue% share of Revenue
Product 1 100%  ?%    ?%
Product 2 100%    ?%    ?%
Product 3 100%   ?%    ?%
Product 4 100%    ?%    ?%
Product 5 100%    ?%   ?%

 

The data comes from a budget fact table linked to a product table and an account group (top row in the table above) table. To make matters more intersting, I also have a slicer with a budget version on the dashboard which should ideally still work 8the fact table contains multiple iterations of the budget).

 

I have two measures - one for the value which is easy enough SUM(budget[Budget_Value] - and the second for the percentage which is where my problem is. These are my attempts so far:

 

Share of Revenue = SUM(budget[Budget_Value]) / CALCULATE(SUM(budget[Budget_Value]),bi_pl_accountgroup[p&l_account-group-EN] = "Revenue")

Result: budget value is filtered on the account group and the costs therefore can't be divided by the revenue (0)

 

Share of Revenue = SUM(budget[Budget_Value] / CALCULATE(SUM(budget[Budget_Value]), ALLSELECTED(),bi_pl_accountgroup[p&l_account-group-EN] = "Revenue")
Result: the account group filter is ignored so the costs on the account groups can be divided by the revenue BUT the product filter is now ignored as well meaning that the comparison only works on the column total.
 
Any help on how to allow the row level but not the column level filter? 
 
I imagine I'm probably not setting up the data in the correct way to do this and/or missing out on some basics so any help would be much appreciated!
1 ACCEPTED SOLUTION

try removing the filter from the table completely:


REMOVEFILTERS ( bi_pl_accountgroup )

View solution in original post

9 REPLIES 9
tamerj1
Super User
Super User

Hi @woombers 

Would please share a screenshot of you data model? What is the type and filter direction between the tables?

thank you

Hi Tamerj

These are the tables. I simplified the naming for the purpose of the message above but basically One to Many with single cross-filter direction for both relevant relationships.

 

woombers_0-1644477480380.png

 

Hi @woombers 
You need to remove the filter comming from the bi_pl_accountgroup[p&l_account-group-EN] column. Try this:

Share of Revenue =
SUM ( budget[Budget_Value] )
    / CALCULATE (
        SUM ( budget[Budget_Value] ),
        REMOVEFILTERS ( bi_pl_accountgroup[p&l_account-group-EN] ),
        bi_pl_accountgroup[p&l_account-group-EN] = "Revenue"
    )

 Please let me know if this solves your problem. If so, kindly mark my reply as accepted soluation. Thank you!

I'm afraid this has the same result as the second measure detailed above. The filter is removed but then added again so that the division of the costs is not calculated vs the revenue

try removing the filter from the table completely:


REMOVEFILTERS ( bi_pl_accountgroup )

That did the trick. Within the measure:

>> Filters removed from the table with REMOVEFILTER

>> Filter reset on the column within the table using the normal CALCULATE

 

Thanks so much for your help. I've spent an embarassing amount of time trying to figure this out

Most welcome dear.

Please let me know if you seek any further help.

 

Have a great Day!
Tamer

Otherwise try this

 

Share of Revenue =
DIVIDE (
    SUM ( budget[Budget_Value] ),
    CALCULATE (
        SUM ( budget[Budget_Value] ),
        FILTER (
            ALL ( bi_pl_accountgroup ),
            bi_pl_accountgroup[p&l_account-group-EN] = "Revenue"
        )
    )
)

 

Also let me add that it is safer in all cases to protect your code using DIVIDE function instead of "/" operator incase you have zeros at the denominator.

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.

Top Solution Authors