cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jason6
Helper I
Helper I

How to calculate >30 days and report for existing month

I have a dataset where i need to track repeat event logged for 0-3, 4-10, 10-30 and >30 for a unique events occuring in a month.

So the columns are as per below , i add a calculated column to capture first report date for each line item and calculate the "Gap"

 

Jason6_1-1663612369326.png

Then i create a measure to check records >30 days and <30 days . Problem is in below screenshot the >30 appears for Aug'22 for Tel # 123 but it is actually >30 days from the event from July'22

Jason6_2-1663612398072.png

What measure should i use to calculate >30 so that it gets reported in July'22 itself as per screenshot below

 

Jason6_3-1663612710743.png

 

 

1 ACCEPTED SOLUTION
alena2k
Resolver III
Resolver III

hi @Jason6 

here is my suggestion for each of measures:

> 30 = 
var tmp = CALCULATE(DISTINCTCOUNT('Table'[Tel #]),
                     ALL('Table'), 
                    'Table'[Tel #] = SELECTEDVALUE('Table'[Tel #]), 
                    'Table'[DateReported] > SELECTEDVALUE('Table'[DateReported]),
                    'Table'[Gap] - SELECTEDVALUE('Table'[Gap]) > 30)
RETURN IF(ISBLANK(tmp), 0, tmp)
< 15 = 
var tmp = CALCULATE(DISTINCTCOUNT('Table'[Tel #]),
                     ALL('Table'), 
                    'Table'[Tel #] = SELECTEDVALUE('Table'[Tel #]), 
                    'Table'[DateReported] > SELECTEDVALUE('Table'[DateReported]),
                     AND('Table'[Gap] - SELECTEDVALUE('Table'[Gap]) < 15, 'Table'[Gap] - SELECTEDVALUE('Table'[Gap]) > 3))
RETURN IF(ISBLANK(tmp), 0, tmp)
< 3 = 
var tmp = CALCULATE(DISTINCTCOUNT('Table'[Tel #]),
                     ALL('Table'), 
                    'Table'[Tel #] = SELECTEDVALUE('Table'[Tel #]), 
                    'Table'[DateReported] > SELECTEDVALUE('Table'[DateReported]),
                     AND('Table'[Gap] - SELECTEDVALUE('Table'[Gap]) > 0, 'Table'[Gap] - SELECTEDVALUE('Table'[Gap]) < 3))
RETURN IF(ISBLANK(tmp), 0, tmp)

The idea is to check if there are any records in future including next months. 

ALL('Table') allows to step out of current context by Tel# and Month. I would use the same approach for all measures in case if you have reports at the end of the month followed by beginning of the next (e.g. 7/31, 8/1)

View solution in original post

2 REPLIES 2
alena2k
Resolver III
Resolver III

hi @Jason6 

here is my suggestion for each of measures:

> 30 = 
var tmp = CALCULATE(DISTINCTCOUNT('Table'[Tel #]),
                     ALL('Table'), 
                    'Table'[Tel #] = SELECTEDVALUE('Table'[Tel #]), 
                    'Table'[DateReported] > SELECTEDVALUE('Table'[DateReported]),
                    'Table'[Gap] - SELECTEDVALUE('Table'[Gap]) > 30)
RETURN IF(ISBLANK(tmp), 0, tmp)
< 15 = 
var tmp = CALCULATE(DISTINCTCOUNT('Table'[Tel #]),
                     ALL('Table'), 
                    'Table'[Tel #] = SELECTEDVALUE('Table'[Tel #]), 
                    'Table'[DateReported] > SELECTEDVALUE('Table'[DateReported]),
                     AND('Table'[Gap] - SELECTEDVALUE('Table'[Gap]) < 15, 'Table'[Gap] - SELECTEDVALUE('Table'[Gap]) > 3))
RETURN IF(ISBLANK(tmp), 0, tmp)
< 3 = 
var tmp = CALCULATE(DISTINCTCOUNT('Table'[Tel #]),
                     ALL('Table'), 
                    'Table'[Tel #] = SELECTEDVALUE('Table'[Tel #]), 
                    'Table'[DateReported] > SELECTEDVALUE('Table'[DateReported]),
                     AND('Table'[Gap] - SELECTEDVALUE('Table'[Gap]) > 0, 'Table'[Gap] - SELECTEDVALUE('Table'[Gap]) < 3))
RETURN IF(ISBLANK(tmp), 0, tmp)

The idea is to check if there are any records in future including next months. 

ALL('Table') allows to step out of current context by Tel# and Month. I would use the same approach for all measures in case if you have reports at the end of the month followed by beginning of the next (e.g. 7/31, 8/1)
jgeddes
Solution Sage
Solution Sage

You will need a column that defines the month/year for the first reported event. The month column you are currently using appears to be based on the date reported. 

Create the new month column and use that in your visual and you should end up with the desired result.

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.