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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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 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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors