Forum Discussion
Adding previous month measure
Hello lbendlin ,
Firts at all, thank you so much for your time.
I've been reviewing what you did, and here are my findings.
1. Total Tickets Solved
Here’s my formula:
total_tickets_solved =
COUNTROWS(
FILTER(
tickets,
RELATED('status'[description]) = "Completed"
)
)And here’s yours:
Tickets Solved = CALCULATE(
DISTINCTCOUNT(Tickets[id]),
USERELATIONSHIP('Calendar'[Date],Tickets[date resolved])
)
I find your way of calculating solved tickets interesting because, from my perspective, what determines if a ticket is solved is its status. In the TICKETS table, this can either be ">Completed" or ">Completed (No Email)."
That’s why I have a STATUS table where the `status` column links to the `status` column in the TICKETS table, and I use that filter in my formula.
2. Total Tickets Solved Previous Month
Here’s my formula:
total_tickets_solved_previous_month =
CALCULATE(
COUNTROWS(
FILTER(
tickets,
RELATED('status'[description]) = "Completed"
)
),
PREVIOUSMONTH('calendar'[date])
)And here’s yours:
Tickets Solved Previous Month =
CALCULATE(
[Tickets Solved],
PREVIOUSMONTH('Calendar'[Date])
)
My formula has a major mistake—I’m not using the `total_tickets_solved` measure, which forces Power BI to recalculate the number of solved tickets. But even after fixing that, the result remains the same: the metric still returns blank or empty.
At this point, I think the problem has to be with the relationship because I can’t find another explanation.
What do you think?
Thank you again,
- lbendlin1 year agoSuper User
RELATED is reserved for use in calculated columns. It is not necessary in measures.
PREVIOUSMONTH by itself won't work as the calendar table is not joined via the "resolved date" but via the "created date. Hence the use of USERELATIONSHIP to temporarily change that.