Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi everyone,
I have this visualization with several metrics. I’d like to add a metric to each card showing the value from the previous month. For example, if I'm viewing the data for August, I want to add a metric at the bottom showing the value for the previous month, along with the percentage difference next to it.
The first step would be to create the metric for the previous month. I understand that Power BI has a function called PREVIOUSMONTH, but I'm not entirely sure how to use it.
I have this formula already:
But the result I’m getting is coming up blank.
The calendar table and the tickets table are related as needed for these cases.
How can I do that?
Thank you guys.
Solved! Go to Solution.
Hi,
There seems to be a problem with the relationship as seen in the second screenshot. Check the columns which you are releating to on the One side of the relationship.
Hello @Ashish_Mathur
Thank you for your reply, but I'm not sure what you mean. Can you tell me where are you whatching the issue on the relationship?
Thank you,
You are welcome. In the first post, you were linking to the ID column of the Status table but in the second one you are connecting to the status column of the status table. I am confused. Share the download link of the PBI file and show the problem there clearly.
Hello,
I have renamed the column for better understanding, see what I just wrote to Ibendlin, there I explain everything.
Let me know if you need anything else.
Thank you,
Formula looks ok. Did you mark your Calendar table as a Date table? Can you confirm you have data for the previous month for that Description filter?
Hello @lbendlin,
Yes, my calendar table is my date table.
calendar =
ADDCOLUMNS(
CALENDAR(DATE(2023,01,01),DATE(2030,12,31)),
"Year", YEAR([DATE]),
"Month", MONTH([DATE]),
"Quarter", FORMAT([DATE], "\QQ"),
"MonthName", FORMAT([DATE], "MMM"),
"WeekDay", FORMAT([DATE], "dddd"),
"DayNumberOfWeek", SWITCH(TRUE(),WeekDay([Date],2) = 1, 1, WeekDay([Date],2) = 2, 2,WeekDay([Date],2) = 3, 3,WeekDay([Date],2) = 4, 4,WeekDay([Date],2) = 5, 5,WeekDay([Date],2) = 6, 6,WeekDay([Date],2) = 7, 7),
"Day", DAY([DATE]),
"FirstMonthDay", FORMAT(EOMONTH([DATE], -1) + 1,"mm/dd/yyyy"),
"FiscalMonth", IF(MONTH([DATE]) >= 7, MONTH([DATE]) - 6, MONTH([DATE]) + 6)
)
Indeed, I do have data for the previous month.
I was thinking about something.
In the ticket table, the status column can contain the value >Complete* or >Complete (No Email), so my understanding is that when the formula specifies:
RELATED('status'[description]) = "Completed", it's searching the ticket table for all records where the status is either >Complete* or >Complete (No Email). Am I wrong?
Thanks for your help.
Guys,
I think the problem is not in the relationship, I have tried this formula and it didn't work either:
tmp =
CALCULATE(
COUNTROWS(
FILTER(
tickets,
tickets[status]=">Completed*" && tickets[status]=">Completed (No email)"
)
),
PREVIOUSMONTH('calendar'[date])
)
Unless the issue is in the relationship of the calendar table.
Any idea?
Thank you so much.
Contrary to natural language, " I want a and b" is expressed in boolean logic via OR (||), not AND (&&)
tmp =
CALCULATE(
COUNTROWS(tickets)
tickets[status] IN {">Completed*",">Completed (No email)"},
PREVIOUSMONTH('calendar'[date])
)
Hello @lbendlin ,
Thanks for your thought, I understand what you are saying.
Let's do it this way:
I have a formula that calculates the resolved tickets.
total_tickets_solved =
COUNTROWS(
FILTER(
tickets,
RELATED('status'[description]) = "Completed"
)
)This formula works smoothly as you can see.
Now my next step is to calculate the number of solved tickets for the previous month. So adding the metric that already works and invoking the previous month function, the formula would be this:
tmp =
CALCULATE(
[total_tickets_solved],
PREVIOUSMONTH('calendar'[date])
)
But it does not work, the result returns blank.
So in my understanding this means that the problem is in the relationship between the ticket table and the calendar table.
Any suggestions to confirm what I think?
Thanks for any comments.
Hi @ajdm2007 ,
Have you done any filtering on the calendar date column?
You referenced the calendar date column in the PREVIOUSMONTH function.
If not, the PREVIOUSMONTH function returns all dates in the previous month using the first date in the calendar date column as input. However, this returns the empty table.
This causes the card visual to return blank.
You can try adding the calendar date column to the slicer, select a date and see if the card visual changes.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @Anonymous ,
Thanks for your input! I do have filters enabled, and there's data in the ticket table as well.
I’m pretty sure the issue is with the calendar table, which is related to the tickets table (calendar - DATE field / tickets - DATEONLY field).
I’m not sure what I might be doing wrong or if there’s an issue with the table, but there are no filters applied to it.
Thank you for any other advise.
Have a good one,
Data model looks good. Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.
Do you mean my datasource?
I don't have a option to attach a file.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
There you go.
I just added few records of three months.
| id | date_entered | date_resolved | status |
| 1667415 | 6/19/2024 16:30 | Scheduled | |
| 1667416 | 6/19/2024 18:04 | 6/19/2024 18:31 | >Completed* |
| 1667417 | 6/20/2024 7:07 | 6/20/2024 7:31 | >Closed |
| 1667418 | 6/20/2024 7:08 | 6/20/2024 7:31 | >Closed |
| 1667419 | 6/20/2024 10:19 | Scheduled | |
| 1667420 | 6/20/2024 15:37 | Waiting on User | |
| 1667421 | 6/21/2024 10:00 | In Progress | |
| 1667437 | 6/24/2024 16:45 | New* | |
| 1667438 | 6/24/2024 16:53 | Waiting on User | |
| 1667439 | 6/24/2024 17:03 | 6/24/2024 19:30 | >Closed |
| 1667440 | 6/25/2024 19:04 | 6/25/2024 19:31 | >Closed |
| 1667441 | 6/25/2024 20:05 | 6/25/2024 21:30 | >Closed |
| 1667442 | 6/25/2024 23:12 | 6/26/2024 7:30 | >Closed |
| 1667443 | 6/26/2024 9:01 | 6/26/2024 9:37 | >Closed |
| 1667444 | 6/26/2024 11:17 | New* | |
| 1667445 | 6/26/2024 11:26 | New* | |
| 1667446 | 6/26/2024 11:58 | Waiting on Vendor | |
| 1667447 | 6/26/2024 14:13 | In Progress | |
| 1667448 | 6/26/2024 17:06 | 6/26/2024 17:31 | >Closed |
| 1667449 | 6/26/2024 19:08 | 6/26/2024 21:38 | >Completed* |
| 1667450 | 6/26/2024 20:03 | 6/26/2024 21:38 | >Completed* |
| 1667451 | 6/26/2024 21:06 | 6/26/2024 21:38 | >Completed* |
| 1667452 | 6/26/2024 23:07 | 6/27/2024 0:31 | >Completed* |
| 1667453 | 6/27/2024 7:06 | 6/27/2024 7:30 | >Completed* |
| 1667454 | 6/27/2024 9:03 | 6/27/2024 9:30 | >Completed* |
| 1667455 | 6/27/2024 9:08 | 6/27/2024 9:30 | >Completed* |
| 1667456 | 6/27/2024 14:32 | Scheduled | |
| 1667457 | 6/27/2024 17:04 | 6/27/2024 18:30 | >Closed |
| 1667458 | 6/27/2024 20:12 | 6/27/2024 21:30 | >Closed |
| 1667459 | 6/27/2024 21:07 | 6/27/2024 22:30 | >Closed |
| 1667460 | 6/28/2024 15:11 | Waiting on User | |
| 1667461 | 6/28/2024 17:04 | Scheduled | |
| 1667462 | 6/28/2024 17:08 | 6/28/2024 18:35 | >Closed |
| 1667463 | 6/28/2024 17:09 | 6/28/2024 17:30 | >Closed |
| 1667464 | 6/28/2024 20:07 | 6/28/2024 20:31 | >Closed |
| 1667465 | 6/28/2024 21:03 | 6/29/2024 11:35 | >Completed* |
| 1667466 | 6/29/2024 18:20 | 6/29/2024 19:31 | >Completed* |
| 1667467 | 6/29/2024 20:08 | 6/29/2024 20:30 | >Completed* |
| 1667468 | 6/29/2024 23:04 | 6/30/2024 8:38 | >Completed* |
| 1667469 | 6/30/2024 0:10 | 6/30/2024 0:35 | >Completed* |
| 1667470 | 6/30/2024 7:12 | 6/30/2024 8:38 | >Completed* |
| 1667471 | 6/30/2024 14:05 | 6/30/2024 18:31 | >Closed |
| 1667474 | 6/30/2024 23:12 | 7/1/2024 0:31 | >Closed |
| 1667475 | 7/1/2024 0:06 | 7/1/2024 7:35 | >Closed |
| 1667476 | 7/1/2024 16:01 | 7/1/2024 16:30 | >Closed |
| 1667477 | 7/1/2024 23:05 | 7/1/2024 23:37 | >Closed |
| 1667478 | 7/2/2024 11:51 | Scheduled | |
| 1667479 | 7/2/2024 13:06 | Scheduled | |
| 1667480 | 7/2/2024 16:59 | 7/2/2024 17:33 | >Closed |
| 1667481 | 7/3/2024 9:34 | Scheduled | |
| 1667482 | 7/3/2024 14:15 | Scheduled | |
| 1667483 | 7/3/2024 20:06 | 7/3/2024 20:31 | >Closed |
| 1667484 | 7/3/2024 23:08 | 7/4/2024 13:31 | >Closed |
| 1667485 | 7/4/2024 7:01 | 7/4/2024 7:35 | >Closed |
| 1667486 | 7/4/2024 7:11 | 7/4/2024 7:35 | >Closed |
| 1667487 | 7/4/2024 14:59 | 7/4/2024 17:30 | >Closed |
| 1667488 | 7/4/2024 15:02 | 7/4/2024 16:30 | >Closed |
| 1667489 | 7/4/2024 16:08 | 7/4/2024 16:30 | >Closed |
| 1667490 | 7/4/2024 19:01 | 7/4/2024 19:30 | >Closed |
| 1667491 | 7/5/2024 0:56 | 7/5/2024 13:33 | >Closed |
| 1667492 | 7/5/2024 15:00 | 7/6/2024 21:31 | >Completed* |
| 1667493 | 7/5/2024 16:01 | 7/5/2024 16:30 | >Completed* |
| 1667494 | 7/5/2024 21:58 | 7/5/2024 22:30 | >Completed* |
| 1667495 | 7/6/2024 0:01 | 7/6/2024 0:30 | >Completed* |
| 1667496 | 7/6/2024 8:10 | 7/6/2024 9:30 | >Completed* |
| 1667497 | 7/6/2024 12:05 | 7/6/2024 12:31 | >Completed* |
| 1667498 | 7/6/2024 14:05 | 7/6/2024 14:30 | >Completed* |
| 1667499 | 7/6/2024 16:00 | 7/6/2024 16:35 | >Completed* |
| 1667500 | 7/6/2024 20:04 | 7/7/2024 0:35 | >Completed* |
| 1667501 | 7/7/2024 7:07 | 7/7/2024 7:30 | >Completed* |
| 1667502 | 7/7/2024 9:04 | 7/7/2024 9:36 | >Completed* |
| 1667503 | 7/7/2024 13:00 | 7/7/2024 13:30 | >Completed* |
| 1667504 | 7/7/2024 13:05 | 7/7/2024 13:30 | >Completed* |
| 1667505 | 7/7/2024 17:05 | 7/7/2024 17:30 | >Completed* |
| 1667522 | 7/9/2024 17:06 | 7/9/2024 17:40 | >Closed |
| 1667523 | 7/9/2024 20:07 | 7/9/2024 20:30 | >Closed |
| 1667524 | 7/10/2024 15:04 | 7/10/2024 15:34 | >Closed |
| 1667525 | 7/10/2024 15:05 | 7/10/2024 15:34 | >Closed |
| 1667526 | 7/10/2024 17:06 | 7/10/2024 17:30 | >Closed |
| 1667631 | 7/29/2024 8:06 | 7/29/2024 8:31 | >Closed |
| 1667632 | 7/29/2024 12:00 | Scheduled | |
| 1667633 | 7/29/2024 12:03 | 7/30/2024 7:30 | >Closed |
| 1667634 | 7/30/2024 9:11 | New* | |
| 1667635 | 7/30/2024 10:44 | New* | |
| 1667636 | 7/30/2024 11:24 | Scheduled | |
| 1667637 | 7/30/2024 12:03 | Scheduled | |
| 1667638 | 7/30/2024 12:41 | Scheduled | |
| 1667639 | 7/30/2024 13:16 | New* | |
| 1667640 | 7/30/2024 13:19 | New* | |
| 1667641 | 7/30/2024 16:56 | In Progress | |
| 1667642 | 7/30/2024 16:57 | Scheduled | |
| 1667643 | 7/30/2024 17:32 | New* | |
| 1667644 | 7/31/2024 7:11 | Scheduled | |
| 1667645 | 7/31/2024 10:09 | New* | |
| 1667646 | 7/31/2024 11:13 | Assigned | |
| 1667647 | 7/31/2024 12:32 | User Has Responded | |
| 1667648 | 7/31/2024 13:04 | 7/31/2024 14:34 | >Closed |
| 1667649 | 7/31/2024 15:28 | In Progress | |
| 1667650 | 7/31/2024 16:25 | New* | |
| 1667651 | 7/31/2024 16:53 | New* | |
| 1667652 | 7/31/2024 17:03 | 7/31/2024 17:31 | >Closed |
| 1667653 | 8/1/2024 11:04 | 8/1/2024 21:32 | >Completed* |
| 1667654 | 8/1/2024 12:08 | 8/1/2024 12:31 | >Completed* |
| 1667655 | 8/2/2024 11:52 | 8/2/2024 11:54 | >Closed |
| 1667656 | 8/2/2024 17:08 | 8/2/2024 17:30 | >Completed* |
| 1667657 | 8/2/2024 22:06 | 8/4/2024 15:30 | >Completed* |
| 1667658 | 8/3/2024 7:06 | 8/4/2024 9:30 | >Completed* |
| 1667659 | 8/3/2024 8:04 | 8/3/2024 8:36 | >Completed* |
| 1667660 | 8/3/2024 9:06 | 8/3/2024 9:30 | >Completed* |
| 1667661 | 8/3/2024 11:58 | 8/3/2024 12:30 | >Completed* |
| 1667662 | 8/3/2024 16:09 | 8/3/2024 17:31 | >Completed* |
| 1667663 | 8/3/2024 19:07 | 8/3/2024 20:35 | >Completed* |
| 1667664 | 8/4/2024 13:07 | 8/4/2024 13:30 | >Completed* |
| 1667665 | 8/4/2024 15:04 | 8/4/2024 15:30 | >Completed* |
| 1667666 | 8/4/2024 20:06 | 8/4/2024 21:30 | >Completed* |
| 1667667 | 8/4/2024 23:07 | 8/4/2024 23:30 | >Completed* |
| 1667668 | 8/5/2024 7:06 | 8/5/2024 8:31 | >Completed* |
| 1667669 | 8/5/2024 11:01 | 8/5/2024 15:32 | >Completed* |
| 1667670 | 8/5/2024 11:01 | 8/6/2024 14:31 | >Completed* |
| 1667671 | 8/5/2024 15:06 | 8/5/2024 15:32 | >Completed* |
| 1667672 | 8/5/2024 17:03 | 8/5/2024 17:30 | >Completed* |
| 1667673 | 8/5/2024 17:09 | 8/5/2024 17:30 | >Completed* |
| 1667674 | 8/6/2024 16:56 | 8/6/2024 17:30 | >Completed* |
| 1667675 | 8/7/2024 18:02 | 8/7/2024 19:30 | >Completed* |
| 1667676 | 8/7/2024 21:01 | 8/7/2024 22:34 | >Completed* |
| 1667677 | 8/8/2024 10:57 | Waiting on User | |
| 1667678 | 8/8/2024 15:46 | New* | |
| 1667679 | 8/8/2024 20:59 | 8/8/2024 23:32 | >Completed* |
| 1667680 | 8/9/2024 9:55 | 8/9/2024 12:31 | >Completed* |
| 1667681 | 8/9/2024 14:45 | New* | |
| 1667682 | 8/9/2024 16:05 | 8/9/2024 16:30 | >Completed* |
| 1667683 | 8/9/2024 21:55 | 8/10/2024 0:32 | >Completed* |
| 1667684 | 8/10/2024 6:59 | 8/10/2024 21:31 | >Completed* |
| 1667685 | 8/10/2024 11:07 | 8/10/2024 21:32 | >Completed* |
| 1667686 | 8/10/2024 19:06 | 8/10/2024 19:30 | >Completed* |
| 1667687 | 8/10/2024 20:49 | In Progress | |
| 1667688 | 8/10/2024 22:04 | 8/10/2024 22:31 | >Completed* |
| 1667694 | 8/12/2024 10:26 | Waiting on Vendor | |
| 1667695 | 8/12/2024 12:06 | New* | |
| 1667696 | 8/12/2024 12:08 | 8/12/2024 13:30 | >Completed* |
| 1667697 | 8/12/2024 14:30 | Scheduled | |
| 1667746 | 8/19/2024 19:58 | 8/19/2024 20:37 | >Completed* |
| 1667752 | 8/21/2024 14:23 | New* | |
| 1667753 | 8/21/2024 15:49 | 8/21/2024 16:30 | >Completed* |
| 1667754 | 8/21/2024 16:58 | 8/21/2024 18:30 | >Completed* |
| 1667755 | 8/21/2024 19:06 | 8/21/2024 21:30 | >Completed* |
| 1667756 | 8/21/2024 20:31 | In Progress | |
| 1667757 | 8/21/2024 21:05 | 8/22/2024 0:31 | >Completed* |
| 1667758 | 8/21/2024 22:51 | 8/21/2024 23:30 | >Completed* |
| 1667759 | 8/22/2024 1:00 | In Progress | |
| 1667760 | 8/22/2024 7:10 | 8/22/2024 7:30 | >Completed* |
| 1667761 | 8/22/2024 9:35 | New* | |
| 1667762 | 8/23/2024 0:01 | 8/23/2024 0:31 | >Completed* |
| 1667763 | 8/23/2024 7:10 | 8/23/2024 7:32 | >Completed* |
| 1667764 | 8/23/2024 15:38 | Scheduled | |
| 1667765 | 8/23/2024 15:50 | 8/23/2024 16:34 | >Completed* |
| 1667766 | 8/23/2024 23:12 | 8/24/2024 13:31 | >Completed* |
| 1667767 | 8/24/2024 15:03 | 8/24/2024 18:31 | >Completed* |
| 1667768 | 8/24/2024 16:08 | 8/25/2024 10:30 | >Completed* |
| 1667769 | 8/24/2024 23:49 | 8/25/2024 9:30 | >Completed* |
| 1667770 | 8/25/2024 0:00 | 8/25/2024 0:30 | >Completed* |
| 1667771 | 8/25/2024 7:07 | 8/25/2024 10:30 | >Completed* |
| 1667772 | 8/25/2024 12:55 | 8/25/2024 17:30 | >Completed* |
| 1667773 | 8/25/2024 13:15 | 8/25/2024 15:30 | >Completed* |
| 1667774 | 8/26/2024 10:45 | New* | |
| 1667775 | 8/26/2024 11:10 | Waiting on User | |
| 1667776 | 8/26/2024 15:11 | New* | |
| 1667777 | 8/27/2024 6:49 | 8/27/2024 7:34 | >Completed* |
| 1667778 | 8/27/2024 8:54 | New* | |
| 1667779 | 8/27/2024 14:52 | Scheduled | |
| 1667780 | 8/27/2024 15:07 | 8/27/2024 15:31 | >Completed* |
| 1667781 | 8/27/2024 15:26 | Scheduled | |
| 1667782 | 8/27/2024 19:05 | 8/27/2024 20:31 | >Completed* |
| 1667783 | 8/28/2024 6:55 | 8/28/2024 7:30 | >Completed* |
| 1667784 | 8/28/2024 8:52 | In Progress | |
| 1667785 | 8/28/2024 9:42 | In Progress | |
| 1667786 | 8/28/2024 11:55 | 8/28/2024 13:30 | >Completed* |
| 1667787 | 8/28/2024 12:07 | 8/29/2024 12:30 | >Completed* |
| 1667788 | 8/28/2024 12:30 | Waiting on User | |
| 1667789 | 8/28/2024 23:10 | 8/29/2024 0:30 | >Completed* |
| 1667790 | 8/29/2024 8:54 | Scheduled | |
| 1667791 | 8/29/2024 9:01 | Scheduled | |
| 1667802 | 8/30/2024 17:40 | New* | |
| 1667803 | 8/30/2024 18:12 | New* | |
| 1667804 | 8/30/2024 20:57 | 8/30/2024 21:30 | >Completed* |
| 1667805 | 8/31/2024 6:08 | New* | |
| 1667806 | 8/31/2024 7:29 | New* | |
| 1667807 | 8/31/2024 8:05 | 8/31/2024 8:30 | >Completed* |
| 1667808 | 8/31/2024 8:53 | New* | |
| 1667809 | 8/31/2024 14:58 | 8/31/2024 15:30 | >Completed* |
| 1667810 | 8/31/2024 16:08 | 8/31/2024 17:30 | >Completed* |
| 1667811 | 8/31/2024 18:05 | 9/1/2024 18:30 | >Completed* |
| 1667812 | 8/31/2024 19:08 | 8/31/2024 19:30 | >Completed* |
| 1667813 | 8/31/2024 20:58 | 8/31/2024 22:30 | >Completed* |
Thank you again
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,
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.
Thank you so much,
Let me take a look, I will keep you posted.
total_tickets_solved =
COUNTROWS(
FILTER(
tickets,
RELATED('status'[description]) = "Completed"
)
)
RELATED has no place in a measure. The relationship is implied through the data model.
total_tickets_solved =
CALCULATE(COUNTROWS(tickets),
'status'[description] = "Completed"
)
In addition you should try and avoid filtering entire tables. Filter columns when possible.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!