Reply
Whoule
Helper I
Helper I

Measure calculating variance between ID

Hi,

 

Here is my table.

IDProcessing CentreTeamCategorySub-CategoryDateNumber Oustanding ItemsDollar Value

2023402xyya 2023-04-1580 $          1,100.00
2023402xyya 2023-04-1580 $        31,100.00
2023402xyya 2023-04-151 $              800.00
2023402xyya 2023-04-15  
2023402xyya 2023-04-1516 $          4,400.00
2023402xyya 2023-04-155 
2023402xyybHigh2023-04-153727 
2023402xyybMedium2023-04-15416 
2023402xyybLow2023-04-15382 
2023402xyybNil2023-04-15921 
2023402xyybNon-Payment2023-04-15217 $  9,181,600.00
2023402xyybConverted2023-04-15280 
2023402xyybRefunds2023-04-15  
2023501xyya 2023-05-011 $          4,443.29
2023501xyya 2023-05-0121 $          5,683.29
2023501xyya 2023-05-012 $              800.00
2023501xyya 2023-05-017 $              800.00
2023501xyya 2023-05-0115 $          6,800.00
2023501xyya 2023-05-015 
2023501xyybHigh2023-05-011550 
2023501xyybMedium2023-05-01500 
2023501xyybLow2023-05-01120 
2023501xyybNil2023-05-011230 
2023501xyybNon-Payment2023-05-01100 $      915,200.00
2023501xyybConverted2023-05-01270 
2023501xyybRefunds2023-05-01  
2023502xyya 2023-05-15500 $        43,400.00
2023502xyya 2023-05-15100 $        43,400.00
2023502xyya 2023-05-154 $          2,600.00
2023502xyya 2023-05-151 $              800.00
2023502xyya 2023-05-1515 $          7,500.00
2023502xyya 2023-05-157 
2023502xyybHigh2023-05-153000 
2023502xyybMedium2023-05-15256 
2023502xyybLow2023-05-15800 
2023502xyybNil2023-05-151200 
2023502xyybNon-Payment2023-05-15229 $  1,956,300.00
2023502xyybConverted2023-05-15249 
2023502xyybRefunds2023-05-15  

 

I am looking for help to build a measure that would calculate the variance of outstanding items between the latest period (either use date column or the ID column) and the period just before the latest. In this example, it would be the variance between period with ID 2023502 and 2023501.

 

Thank you.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Whoule , try a measure like

 

Variance Items =
VAR _lastest = MAX('Table'[ID])
VAR _previous= CALCULATE(MAX('Table'[ID]), 'Table'[ID] < _lastest)

VAR _latest_out = CALCULATE(SUM('Table'[Number Oustanding Items]), 'Table'[ID] = _lastest)
VAR _previous_out = CALCULATE(SUM('Table'[Number Oustanding Items]), 'Table'[ID] = PreviousPeriodID)

RETURN
IF(ISBLANK(_latest_out) || ISBLANK(_previous_out), BLANK(),
_latest_out - _previous_out)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Whoule , try a measure like

 

Variance Items =
VAR _lastest = MAX('Table'[ID])
VAR _previous= CALCULATE(MAX('Table'[ID]), 'Table'[ID] < _lastest)

VAR _latest_out = CALCULATE(SUM('Table'[Number Oustanding Items]), 'Table'[ID] = _lastest)
VAR _previous_out = CALCULATE(SUM('Table'[Number Oustanding Items]), 'Table'[ID] = PreviousPeriodID)

RETURN
IF(ISBLANK(_latest_out) || ISBLANK(_previous_out), BLANK(),
_latest_out - _previous_out)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 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 (Last Month)
Top Kudoed Authors (Last Month)