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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Analitika
Post Prodigy
Post Prodigy

How to calculate difference between different rows and columns in the same table in Power BI?

Hello,

 

I am trying to calculate the difference between values which are in different rows and columns. When I am trying to calculate I am getting a wrong result. Seems my query calculates difference by values in same row.

Here is my data table example:

Analitika_0-1634197675267.png

My expected result is:

Analitika_1-1634197709163.png

My output result is:

Analitika_2-1634197783742.png

 

Seems that result is wrong. I expected to 0.87 but I am  getting -3289,13. So what's wrong here in my DAX fomula?

My query is here:

Column =
VAR _0 = MINX(FILTER('DBA view_DidknObj','DBA view_DidknObj'[DID_DAT]> EARLIER('DBA view_DidknObj'[DID_DAT]) && 'DBA view_DidknObj'[SAS_KOD]= EARLIER('DBA view_DidknObj'[SAS_KOD])),[DID_DAT])
VAR _1 = MAXX(FILTER('DBA view_DidknObj','DBA view_DidknObj'[DID_DAT] =_0 && 'DBA view_DidknObj'[SAS_KOD]= EARLIER('DBA view_DidknObj'[SAS_KOD]) ),[SUM_CRE])
return
if('DBA view_DidknObj'[SAS_KOD] <> 0,_1 - 'DBA view_DidknObj'[SUM_DEB], blank())

 

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

Best regards

How you could get the different values from the columns in such an array.

The idea is that I should compare prices between the different production batches and paint red the row that has at least a different price.

Angel_Borbor_0-1717534499342.png

V-lianl-msft
Community Support
Community Support

Unfortunately, I don't know your calculation logic. The fields in your formula are inconsistent with the sample data you provided, so it's difficult to correctly express what you mean. Please provide a pbix file after deleting sensitive data and the calculation logic you want to implement.

amitchandak
Super User
Super User

@Analitika , Try these

 

Calc 1 =
var _1 = maxx(FILTER('Table', [ID] =EARLIER('Table'[ID]) && [CRE]<>0) ,[CRE])
return if([DET] <>0, _1 -[DET])

or


Calc 12 =
var _1 = maxx(FILTER('Table', [ID] =EARLIER('Table'[ID]) && [CRE]<>0 && [DATE] >EARLIER('Table'[DATE]) ) ,[CRE])
return if([DET] <>0, _1 -[DET])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello having error

Calc 1 =
var _1 = maxx(FILTER('DBA view_DidknObj', [SAS_KOD] =EARLIER('DBA view_DidknObj'[SAS_KOD]) && [SUM_CRE]<>0) ,[SUM_CRE] && FILTER('DBA view_DidknObj','DBA view_DidknObj'[id] in {20210}))
return if([SUM_DEB] <>0, _1 -[SUM_DEB]) Analitika_0-1634211276763.png

 

 

@amitchandak Yes I have tried but is possible to include filter Id like id=500 because there are more rows in data? In the same query I mean.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors