Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi All,
I have a Customer Table with Customer Visitation date and Customer ID. I need to setup a visitaion counter/Number for each of the Customer Visit.
I also would require the Visitaion counter to reset to 1 when i change the add new data and drop off older data. Eg, Drop off the earliet week and Add 1 new week of data.
| Customer ID | Visit Date | Visitaion Counter |
| 1 | 12-Aug | 1 |
| 1 | 13-Aug | 2 |
| 2 | 14-Aug | 1 |
| 1 | 15-Aug | 3 |
| 2 | 16-Aug | 2 |
| 3 | 17-Aug | 1 |
Let me if there is a way to Acheive this,
Thanks in Advance for the help.
Regards,
Ashwin
Solved! Go to Solution.
Hi @ctashwin ,
You need a measure instead:
Measure =
RANKX(FILTER(ALLSELECTED('Table'),'Table'[Customer ID ]=MAX('Table'[Customer ID ])),CALCULATE(MAX('Table'[Visit Date])),,ASC)
And you will see:
The counter will be changed by the selection of dates.
For the related .pbix file,pls see attached.
Hi @ctashwin ,
You need a measure instead:
Measure =
RANKX(FILTER(ALLSELECTED('Table'),'Table'[Customer ID ]=MAX('Table'[Customer ID ])),CALCULATE(MAX('Table'[Visit Date])),,ASC)
And you will see:
The counter will be changed by the selection of dates.
For the related .pbix file,pls see attached.
Hey @ctashwin ,
based on the sample data you provided this calculated column creates the expected result:
Column =
RANKX(
CALCULATETABLE(
SUMMARIZE(
'Table'
, 'Table'[Customer ID ]
, 'Table'[Visit Date]
)
, ALL('Table'[Visit Date])
)
, 'Table'[Visit Date]
,
, ASC
)
You just have to make sure, that the values of the column [Visit Date] can be ordered, for this reason I converted the column to the data type date.
Here is a little screenshot:
Hopefully, this provides what you are looking for.
Regards,
Tom
Hi Tom,
Thanks for the reply.
The caclulated column works, but the issue i am facing is i have 2 years worth of data and calculated column creates a counter from day 1 in this case ie if a customer is regular and visits twice a month, his visit counter would give me like 24 for this month.
I am trying to achieve a similar thing, where when i select the last 3 months, the visitaion counter should reset to 1 and start coutning forward.
Thanks for the help
Ashwin
Hey @ctashwin ,
please provide sample data, and explain what do you mean by "select the last 3 months". Do you select the the last 3 month inside a report by using a slicer or a filter?
Also provide the expected result as in your initial post.
Regards,
Tom
@ctashwin - Try:
Column =
COUNTROWS(FILTER('Table',[Customer ID] = EARLIER([Customer ID]) && [Visit Date] <= EARLIER([Visit Date]) && [Visit Date]>=TODAY()-90 ))
Measure
VAR __CustomerID = MAX([Customer ID])
VAR __VisitDate = MAX([Visit Date])
RETURN
COUNTROWS(FILTER('Table',[Customer ID] = __CustomerID && [Visit Date] <= __VisitDate && [Visit Date]>=TODAY()-90 ))
@ctashwin - Try:
Column =
COUNTROWS(FILTER('Table',[Customer ID] = EARLIER([Customer ID]) && [Visit Date] <= EARLIER([Visit Date])))
@ctashwin , try a new column like
countx(filter(Table, [Customer ID] = earlier([Customer ID]) && [Visit Date] = earlier([Visit Date])),[Visit Date] )
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 55 | |
| 34 | |
| 31 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 74 | |
| 71 | |
| 38 | |
| 35 | |
| 25 |