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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors