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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sse
Regular Visitor

Last country visited timeline logic

Hi! I am struggling to figure this out and would appreciate some help. 

 

I am trying to make a PowerBi report that shows "Which country did people vist before they came to their current country". The user of the dashboard would typically select a country and see the previous country visited. The end product should be able to show all previous countries visited but as a starter the previous country would suffice. 

 

I can easily build this for each person, but I am struggling to create an aggregated view. E.g., when I select Germany I can see that 500, 300 and 250 people visited France, UK and USA before visiting Germany. 

 

Any tips? 

 

power.png

2 ACCEPTED SOLUTIONS
cs_skit
Resolver IV
Resolver IV

this was a pretty tough one for me thanks for that was fun

 

created calculated column

 

VisitOrder = COUNTROWS
(
FILTER(countryvisits;EARLIER(countryvisits[Person])= countryvisits[Person] && EARLIER(countryvisits[DateCol])>countryvisits[DateCol])
)
+1

 

created second calculated column

 

LastCountry = CONCATENATEX
(
FILTER(countryvisits;EARLIER(countryvisits[Person])=countryvisits[Person]&&EARLIER(countryvisits[VisitOrder])-1 = countryvisits[VisitOrder])
;countryvisits[Country]
)

 

result

 

 

View solution in original post

v-shex-msft
Community Support
Community Support

Hi @sse,

 

You can try to use below formula to get the result table if it suitable for your requirement.

 

Table formula:

Person Country Records = 
ADDCOLUMNS(
    SUMMARIZE(Table,[Person],"Country",LASTNONBLANK(Table[Country],[Country]),"Last Timestamp",LASTTimestamp(Table[Timestamp])),
    "Previous",LOOKUPVALUE(Table[Country],[Person],[Person],[Timestamp],MAXX(FILTER(ALL(Table),[Person]=EARLIER([Person])&&[Timestamp]<EARLIER([Last Timestamp])),[Timestamp]))
    )

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @sse,

 

You can try to use below formula to get the result table if it suitable for your requirement.

 

Table formula:

Person Country Records = 
ADDCOLUMNS(
    SUMMARIZE(Table,[Person],"Country",LASTNONBLANK(Table[Country],[Country]),"Last Timestamp",LASTTimestamp(Table[Timestamp])),
    "Previous",LOOKUPVALUE(Table[Country],[Person],[Person],[Timestamp],MAXX(FILTER(ALL(Table),[Person]=EARLIER([Person])&&[Timestamp]<EARLIER([Last Timestamp])),[Timestamp]))
    )

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
cs_skit
Resolver IV
Resolver IV

this was a pretty tough one for me thanks for that was fun

 

created calculated column

 

VisitOrder = COUNTROWS
(
FILTER(countryvisits;EARLIER(countryvisits[Person])= countryvisits[Person] && EARLIER(countryvisits[DateCol])>countryvisits[DateCol])
)
+1

 

created second calculated column

 

LastCountry = CONCATENATEX
(
FILTER(countryvisits;EARLIER(countryvisits[Person])=countryvisits[Person]&&EARLIER(countryvisits[VisitOrder])-1 = countryvisits[VisitOrder])
;countryvisits[Country]
)

 

result

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.