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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to calculate lengths by the same order number

image.png

 

This is the table that I have and I'm trying to make a measure that does (NewLength - 200Length)/200 length for the same order number.

 

The desired output for the measure with this dataset is 0.02289.

 

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measure like DAX below.

 

Measure1 = 
var _PrevDate = CALCULATE(MAX('Table'[Date]), FILTER( ALLEXCEPT('Table', 'Table'[Number]), 'Table'[ Date] <  MAX('Table'[ Date])))
var _PrevNewLength = CALCULATE(FIRSTNONBLANK('Table'[NewLength], 1),  FILTER( ALLEXCEPT('Table', 'Table'[Number]), 'Table'[ Date]= _PrevDate))
RETURN
DIVIDE(_PrevNewLength- MAX('Table'[ 200 length]), MAX('Table'[ 200 length]), 0)

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measure like DAX below.

 

Measure1 = 
var _PrevDate = CALCULATE(MAX('Table'[Date]), FILTER( ALLEXCEPT('Table', 'Table'[Number]), 'Table'[ Date] <  MAX('Table'[ Date])))
var _PrevNewLength = CALCULATE(FIRSTNONBLANK('Table'[NewLength], 1),  FILTER( ALLEXCEPT('Table', 'Table'[Number]), 'Table'[ Date]= _PrevDate))
RETURN
DIVIDE(_PrevNewLength- MAX('Table'[ 200 length]), MAX('Table'[ 200 length]), 0)

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

az38
Community Champion
Community Champion

Hi @Anonymous 

try a measure

Measure = 
var _NewLength = MAX(Table[NewLength])
var _Length200 = CALCULATE(MAX(Table[Length]), ALLEXCEPT(Table, Table[Number]), Table[Code] = 200)

RETURN
DIVIDE(
(_NewLength - _Length200 ),
_Length200
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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 Solution Authors