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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Row Difference (Using 2 Index Columns)

Good Afternoon All,

 

Ive been going around in circles with this for a while, i appreciate it may seem easy but i just cant get it to work.

 

I have a table with information from our production line, it basically keeps a running count of our production counter every hour. I can see the values as shown below & I know if I subract the container count associated with SIC_ID 1 from SIC_ID 2 I get 30,002. But how do i do this in power BI automatically?

 

PowerBi.png

 

Currently there are different lines recorded to this table & the SIC_ID is 1 to 24 then resets & starts over again. Im assuming I need to filter on Line & ID, Any suggestions?

 

Thanks,

Ash

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

There's a pattern for getting the previous value ( this should work for your initial scenario, you might need to change it for the full scenario)

Previous Val Column = VAR _line = ProdLine[line]
              VAR _sic = ProdLine[sic_id]
RETURN
    CALCULATE(SUM(ProdLine[con]), 
        FILTER(ProdLine,
            ProdLine[line] = _line && 
            ProdLine[sic_id] =  _sic -1))

You then have the previous value on the same line as the current value so you can add a column to subtract one from the other

View solution in original post

2 REPLIES 2
HotChilli
Super User
Super User

There's a pattern for getting the previous value ( this should work for your initial scenario, you might need to change it for the full scenario)

Previous Val Column = VAR _line = ProdLine[line]
              VAR _sic = ProdLine[sic_id]
RETURN
    CALCULATE(SUM(ProdLine[con]), 
        FILTER(ProdLine,
            ProdLine[line] = _line && 
            ProdLine[sic_id] =  _sic -1))

You then have the previous value on the same line as the current value so you can add a column to subtract one from the other

Anonymous
Not applicable

You're a star! thankyou

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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