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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Shir___
New Member

Calculation of measure/column- based on next date in a partition by case with multiple rows per date

 

I have a table with customer id and order date (and various other fields).

Each order date and customer has multiple rows (see example).

In addition, I have in another column the date we stopped working with the customer.

 

I would like to calculate the # of customers who had their next order in under 6 months, and the number of customers who we stopped working with (left) 6 months or less after their order date.

 

See this table to better understand what should be counted

 

Shir____0-1711745799919.png

 

Appreciate the help!

 

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

The next time you hare some data, share it in a format that can be pasted in an MS Excel file.  Sharing an image is useless.  These calculated column formulas work

Next order within 6 months? = if(ISBLANK(CALCULATE(MIN(Data[order date]),FILTER(Data,Data[Customer id]=EARLIER(Data[Customer id])&&Data[order date]>EARLIER(Data[order date])))),BLANK(),if(DATEDIFF(Data[order date],CALCULATE(MIN(Data[order date]),FILTER(Data,Data[Customer id]=EARLIER(Data[Customer id])&&Data[order date]>EARLIER(Data[order date]))),MONTH)<=6,1,BLANK()))
Column = if(ISBLANK(Data[Next order within 6 months?]),if(DATEDIFF(Data[order date],Data[date stopped working],MONTH)<=6&&DATEDIFF(Data[order date],Data[date stopped working],MONTH)>0,1,BLANK()),BLANK())

Hope this helps.

Ashish_Mathur_0-1711769887815.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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