cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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"

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

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

1 ACCEPTED SOLUTION
Resolver IV

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)
2 REPLIES 2
Resolver IV

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)
Super User

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.

Proud to be a Super User!

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors