Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Crime Analysis Table

I am trying to do a real time crime analysis table visual based off of a live sql query. I have a data table which has columns that provides the date (date_occurred) the crime took place, the uniform crime report (ucr) number and  the description (UCR_description) for each UCR code.

Date OccurredUCR CodeCode Description
1/1/20110H
1/1/20210S
1/1/20740AU
1/1/20600B
1/1/20600B
1/1/20310R
1/1/20310R
1/1/20310R
1/1/20210S
12/12/19820T
12/12/19820T
12/12/19810T
12/12/19740AU
12/12/19900AR
12/12/19110H
12/12/19210S
12/12/19210S
12/12/19600B
1/17/20600B
1/17/20310R
1/17/20310R
1/17/20310R
1/17/20210S
1/17/20820T
1/17/20820T
1/17/20810T
1/17/20740AU
1/17/20900AR
1/17/20900AR

 

I am trying to do a year to date comparision by each UCR code that would produce a table visual like this:

UCR Description20202019% Change
110H110.00%
210S12-50.00%
310R60600.00%
600B31200.00%
740AU21100.00%
810T110.00%
820T220.00%
900AR21100.00%

 

I can get the table visual to work for YTD 2020 but can not figure out how to show the year to date comparision between 2020 and 2019. The year to date would always compair this year to last year. 

 

Any help would be appreciated.

2 Replies

  • Anonymous there are lots of posts on comparing with Previous Year and the key is to add date/calendar dimension in your model. There are many posts on how you add date/calendar dimension and as it is a best practice to do all Time Intelligence calculations from this date/calendar dimension. This is your starting point and you will easily get it working using time intelligence functions.

     

     

    I would 💖 Kudos 🙂 if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!