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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Miniso
Frequent Visitor

Count Number of day

Hello,

 

I would like to write a Dax formula, counting number of Days based on Product ID. I do not have the start and end date in two diff columns.

 

Thanks Much Appreciated.

 

Miniso_0-1677617957928.png

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

CalculatedColumn=VAR _prev=MAXX(FILTER(Table,Table[Product]=EARLIER(Table[Product])&&Table[Date]<EARLIER(Table[Date])),Table[Date] RETURN IF(_prev,Table[Date]-_prev)

Measure=VAR _Curr=MAX(Table[Date]) VAR _Prev=CALCULATE(MAX(Table[Date]),Table[Date]<_Curr) RETURN IF(_Prev,_Curr-_Prev)

View solution in original post

2 REPLIES 2
Miniso
Frequent Visitor

Thanks!

wdx223_Daniel
Super User
Super User

CalculatedColumn=VAR _prev=MAXX(FILTER(Table,Table[Product]=EARLIER(Table[Product])&&Table[Date]<EARLIER(Table[Date])),Table[Date] RETURN IF(_prev,Table[Date]-_prev)

Measure=VAR _Curr=MAX(Table[Date]) VAR _Prev=CALCULATE(MAX(Table[Date]),Table[Date]<_Curr) RETURN IF(_Prev,_Curr-_Prev)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors