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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.