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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculating a residual.

Hi,

 

I have a sales table with sales on different aggregated levels. A simplification is like this:

 

MarketSales
Total Market100
Customer A75
Banner A120
Banner A230
Banner A325
Customer B25
Banner B110
Banner B25
Banner B35

 

So the table holds both Total sales (per sku, per period ect) and sales per customer and per banner (sub customer). When summing banners for Customer B (Banner B1 to B3) they do not sum up to total Customer B - there is a residual. So - I want to calculate the residual and would like to have it on the same table as a "Banner B4 (other)"

 

MarketSales
Total Market100
Customer A75
Banner A120
Banner A230
Banner A325
Customer B25
Banner B110
Banner B25
Banner B35
Banner B4 (other)5

 

But I have no idea how to approach that - any guidance in the right direction would be appreciated...!

 

Br Kent

1 ACCEPTED SOLUTION

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Try this calculated Table

 

From the Modelling Tab>>New Table

 

Calculated Table =
VAR AddColumn =
    ADDCOLUMNS (
        Table1,
        "Missing Sales",
        VAR myCustomer =
            IF ( SEARCH ( "Customer", [Market], 1, 0 ) > 0, RIGHT ( [Market], 1 ) )
        VAR mysales =
            CALCULATE (
                SUM ( Table1[Sales] ),
                FILTER ( Table1, SEARCH ( "Banner " & myCustomer, Table1[Market], 1, 0 ) > 0 )
            )
        VAR MaxBanner =
            CALCULATE (
                MAX ( Table1[Market] ),
                FILTER ( Table1, SEARCH ( "Banner " & myCustomer, Table1[Market], 1, 0 ) > 0 )
            )
        RETURN
            IF (
                SEARCH ( "Customer", [Market], 1, 0 ) > 0
                    && ( [Sales] - mysales )
                    > 0,
                "Banner " & myCustomer
                    & RIGHT ( MaxBanner, 1 ) + 1
                    & " (other)"
                    & "|"
                    & [Sales] - mysales
            )
    )
VAR desiredrows =
    FILTER (
        SELECTCOLUMNS (
            AddColumn,
            "Market", PATHITEM ( [Missing Sales], 1 ),
            "Sales", PATHITEM ( [Missing Sales], 2, 1 )
        ),
        [Sales] > 0
    )
RETURN
    UNION ( desiredrows, Table1 )

@Anonymous

 

Please see attached file as well

 

residual.png

Anonymous
Not applicable

PERFECT - Thank You very much!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.