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
sviv321
Regular Visitor

Revenue proportion ignoring negatives with correct totals

Hi,

 

I am new to Power BI.

I am trying to calculate proportion of revenue by clients & by products (Output Table below).

 

I am able to calcultae the "Revenue %" column; but i am not successful in getting the last two columns "Revenue (excl -ve clients)" "Revenue % (Only considering Net +ve Clients)".

In this column I want to ignore clients with negative revenue (after summing up client level revenue). 

 

I have a slicer on report page to select the Product.

Also, I will use this % output to calculate further measures.

 

Any help would be great.

 

Below are the required tables:

 

Data Table Input
   
ProductClientRevenue
A110
A1-20
A230
A240
A320
A445
A425
B2-40
B110
B120
B320
B310
B445
B425

 

Output Required     
      
ProductClientRevenueRevenue %Revenue (excl -ve clients)Revenue % (Only considering Net +ve Clients)
A1-10-6.7%                -  0.0%
A27046.7%               7043.8%
A32013.3%               2012.5%
A47046.7%               7043.8%
Total 150100.0%             160100.0%
      
      
ProductClientRevenueRevenue %Revenue (excl -ve clients)Revenue % (Only considering Net +ve Clients)
B13033.3%                  3023.1%
B2-40-44.4%                   -  0.0%
B33033.3%                  3023.1%
B47077.8%                  7053.8%
Total 90100.0%130100.0%
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @sviv321 

I have a test by your sample, I think you need to add a PC code column to build Revenue % (Only considering Net +ve Clients).

PC Code = 'Data Table Input'[Product]&""&'Data Table Input'[Client]

1.png

Then let's build measures to show the result.

Revenue% = 
DIVIDE (
    SUMX (
        SUMMARIZE (
            'Data Table Input',
            'Data Table Input'[Product],
            'Data Table Input'[Client],
            'Data Table Input'[Revenue]
        ),
        [Revenue]
    ),
    SUMX ( ALLSELECTED ( 'Data Table Input' ), 'Data Table Input'[Revenue] )
)
%Revenue (excl -ve clients) = 
VAR _T =
    SUMMARIZE (
        'Data Table Input',
        'Data Table Input'[Product],
        'Data Table Input'[Client],
        "Revenue", SUM ( 'Data Table Input'[Revenue] )
    )
RETURN
    SUMX ( FILTER ( _T, [Revenue] > 0 ), [Revenue] )
Revenue % (Only considering Net +ve Clients) = 
VAR _PCcode =
    CALCULATETABLE (
        VALUES ( 'Data Table Input'[PC Code] ),
        FILTER ( ALL ( 'Data Table Input' ), 'Data Table Input'[Revenue] < 0 )
    )
VAR _Total =
    SUMX (
        FILTER (
            ALLSELECTED ( 'Data Table Input' ),
            NOT ( 'Data Table Input'[PC Code] IN _PCcode )
        ),
        'Data Table Input'[Revenue]
    )
RETURN
    DIVIDE ( [%Revenue (excl -ve clients)], _Total ) + 0

Result is as below.

3.png

Select A:

4.png

Select B:

6.png

Best Regards,

Rico 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

4 REPLIES 4
v-rzhou-msft
Community Support
Community Support

Hi @sviv321 

I have a test by your sample, I think you need to add a PC code column to build Revenue % (Only considering Net +ve Clients).

PC Code = 'Data Table Input'[Product]&""&'Data Table Input'[Client]

1.png

Then let's build measures to show the result.

Revenue% = 
DIVIDE (
    SUMX (
        SUMMARIZE (
            'Data Table Input',
            'Data Table Input'[Product],
            'Data Table Input'[Client],
            'Data Table Input'[Revenue]
        ),
        [Revenue]
    ),
    SUMX ( ALLSELECTED ( 'Data Table Input' ), 'Data Table Input'[Revenue] )
)
%Revenue (excl -ve clients) = 
VAR _T =
    SUMMARIZE (
        'Data Table Input',
        'Data Table Input'[Product],
        'Data Table Input'[Client],
        "Revenue", SUM ( 'Data Table Input'[Revenue] )
    )
RETURN
    SUMX ( FILTER ( _T, [Revenue] > 0 ), [Revenue] )
Revenue % (Only considering Net +ve Clients) = 
VAR _PCcode =
    CALCULATETABLE (
        VALUES ( 'Data Table Input'[PC Code] ),
        FILTER ( ALL ( 'Data Table Input' ), 'Data Table Input'[Revenue] < 0 )
    )
VAR _Total =
    SUMX (
        FILTER (
            ALLSELECTED ( 'Data Table Input' ),
            NOT ( 'Data Table Input'[PC Code] IN _PCcode )
        ),
        'Data Table Input'[Revenue]
    )
RETURN
    DIVIDE ( [%Revenue (excl -ve clients)], _Total ) + 0

Result is as below.

3.png

Select A:

4.png

Select B:

6.png

Best Regards,

Rico Zhou

 

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

 

@v-rzhou-msft 

 

It worked for me. Thanks for your help!!! 🙂 

amitchandak
Super User
Super User

@sviv321 , Try a measure like

calculate(divide(sum(Table[Revenue]), calculate(sum(Table[Revenue]), allselected(Table))), filter(Table, Table[Revenue]>0))

@amitchandak ,

Thanks for the quick response.

I tried the formula you suggested, but it is returning 100% for all rows.

 

I even tried replacing SUM with SUMX, but that didn't help either.

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.