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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
nikca
Regular Visitor

Sum by codebook

Hello guys, 

 

i have two tables: 

Table 1 
TextNumber
010010        10,5
011000           11
210100        250

 

 

Table 2 
CategoryText
010010010
011011000
210210100

 

In table 1, I using Measure, to sum all numbers related to text (text are more times in table). 

Table 2 is codebook to text. 

 

All i need is to get different for example between 010-011, which is -0,5. 

But, I don´t know how. 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @nikca 
You can achieve it using offset fumction

Ritaf1983_0-1687657430149.png

The steps :

Ritaf1983_1-1687657470280.png

2. Calculate basic sum

Sum_number = sum('Table'[Number])
3. Calculate your needed delta
ValuesDiff =
[Sum_number] - CALCULATE (
        [Sum_number],
        OFFSET ( -1, ALLSELECTED ( 'Table (2)'[Category] ), ORDERBY ( 'Table (2)'[Category], ASC ) )
    )
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

1 REPLY 1
Ritaf1983
Super User
Super User

Hi @nikca 
You can achieve it using offset fumction

Ritaf1983_0-1687657430149.png

The steps :

Ritaf1983_1-1687657470280.png

2. Calculate basic sum

Sum_number = sum('Table'[Number])
3. Calculate your needed delta
ValuesDiff =
[Sum_number] - CALCULATE (
        [Sum_number],
        OFFSET ( -1, ALLSELECTED ( 'Table (2)'[Category] ), ORDERBY ( 'Table (2)'[Category], ASC ) )
    )
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.