Forum Discussion
Get next visit on a customer
- Anonymous7 years ago
Hi ruban
The same solution can be achedived by creating a calculated column as well.
Next Visist Date = CALCULATE(MIN('Customer Visit Table'[Visit_Date]), FILTER('Next Visit Date','Customer Visit Table'[CID]= EARLIER('Customer Visit Table'[CID]) && 'Customer Visit Table'[Visit_Date] >EARLIER('Customer Visit Table'[Visit_Date])))Please note that this will not respond to slicer selection as its calculated column.
Thanks
Raj
Did i answer your Question? Please mark my answer as Solution.
Proud to be a Datanaut!
Hi ruban
Please create the new calculated table using this DAX:
New Next Visit Table =
VAR vSelfjoin= FILTER(
GENERATE('Customer Visit Table',
SELECTCOLUMNS('Customer Visit Table',
"xCID" , 'Customer Visit Table'[CID],
"xVisit_Date", 'Customer Visit Table'[Visit_Date])
)
,'Customer Visit Table'[CID]=[xCID] &&
[xVisit_Date]>'Customer Visit Table'[Visit_Date]
)
VAR vLastVisitDate = GROUPBY(vSelfjoin,
'Customer Visit Table'[CID],
'Customer Visit Table'[Visit_Date],
"Next Visit Date", MINX(CURRENTGROUP(),[xVisit_Date])
)
RETURN NATURALLEFTOUTERJOIN('Customer Visit Table',vLastVisitDate)
Then pull the columns from this new table:
Thanks
Raj
Did i answer your Question? Please mark my answer as Solution.
Proud to be a Datanaut!
Hi ruban
The same solution can be achedived by creating a calculated column as well.
Next Visist Date = CALCULATE(MIN('Customer Visit Table'[Visit_Date]),
FILTER('Next Visit Date','Customer Visit Table'[CID]= EARLIER('Customer Visit Table'[CID])
&& 'Customer Visit Table'[Visit_Date] >EARLIER('Customer Visit Table'[Visit_Date])))
Please note that this will not respond to slicer selection as its calculated column.
Thanks
Raj
Did i answer your Question? Please mark my answer as Solution.
Proud to be a Datanaut!
- ruban7 years agoFrequent Visitor
Hi Raj,
Could you share the table image when you use calculated column?
Regards,
Ruban
- Anonymous7 years agoNot applicable
Its same as above image. Thanks Raj
- ruban7 years agoFrequent Visitor
Hi Raj,
When I use your DAX for the calculated column , I get the previous visit date instead of next visit date . Could you hep me solve it?