Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ajdm2007
Helper III
Helper III

Adding previous month measure

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.

ajdm2007_0-1726258641183.png

 

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:

total_tickets_solved_previous_month =
CALCULATE(
    COUNTROWS(
        FILTER(
            tickets,
            RELATED('status'[Description]) = "Completed"
        )
    ),
    PREVIOUSMONTH('calendar'[Date])
)
 

But the result I’m getting is coming up blank.

 

The calendar table and the tickets table are related as needed for these cases.

 

ajdm2007_0-1726260653476.png ajdm2007_1-1726260673065.png

 

 

How can I do that?

 

Thank you guys.

 

 

 

1 ACCEPTED SOLUTION

21 REPLIES 21
Ashish_Mathur
Super User
Super User

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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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?

 

ajdm2007_0-1726358027842.png

 

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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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,

lbendlin
Super User
Super User

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

 

 

ajdm2007_1-1726358980204.png

 

 

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"
    )
)

ajdm2007_0-1726427985036.png

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.

ajdm2007_1-1726428795745.png

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.

Anonymous
Not applicable

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.

vdengllimsft_0-1726478689989.png


You can try adding the calendar date column to the slicer, select a date and see if the card visual changes.

vdengllimsft_1-1726479050583.pngvdengllimsft_2-1726479069456.png

 

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).

ajdm2007_0-1726490629928.png

 

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.

There you go.

 

I just added few records of three months.

 

iddate_entereddate_resolvedstatus
16674156/19/2024 16:30 Scheduled
16674166/19/2024 18:046/19/2024 18:31>Completed*
16674176/20/2024 7:076/20/2024 7:31>Closed
16674186/20/2024 7:086/20/2024 7:31>Closed
16674196/20/2024 10:19 Scheduled
16674206/20/2024 15:37 Waiting on User
16674216/21/2024 10:00 In Progress
16674376/24/2024 16:45 New*
16674386/24/2024 16:53 Waiting on User
16674396/24/2024 17:036/24/2024 19:30>Closed
16674406/25/2024 19:046/25/2024 19:31>Closed
16674416/25/2024 20:056/25/2024 21:30>Closed
16674426/25/2024 23:126/26/2024 7:30>Closed
16674436/26/2024 9:016/26/2024 9:37>Closed
16674446/26/2024 11:17 New*
16674456/26/2024 11:26 New*
16674466/26/2024 11:58 Waiting on Vendor
16674476/26/2024 14:13 In Progress
16674486/26/2024 17:066/26/2024 17:31>Closed
16674496/26/2024 19:086/26/2024 21:38>Completed*
16674506/26/2024 20:036/26/2024 21:38>Completed*
16674516/26/2024 21:066/26/2024 21:38>Completed*
16674526/26/2024 23:076/27/2024 0:31>Completed*
16674536/27/2024 7:066/27/2024 7:30>Completed*
16674546/27/2024 9:036/27/2024 9:30>Completed*
16674556/27/2024 9:086/27/2024 9:30>Completed*
16674566/27/2024 14:32 Scheduled
16674576/27/2024 17:046/27/2024 18:30>Closed
16674586/27/2024 20:126/27/2024 21:30>Closed
16674596/27/2024 21:076/27/2024 22:30>Closed
16674606/28/2024 15:11 Waiting on User
16674616/28/2024 17:04 Scheduled
16674626/28/2024 17:086/28/2024 18:35>Closed
16674636/28/2024 17:096/28/2024 17:30>Closed
16674646/28/2024 20:076/28/2024 20:31>Closed
16674656/28/2024 21:036/29/2024 11:35>Completed*
16674666/29/2024 18:206/29/2024 19:31>Completed*
16674676/29/2024 20:086/29/2024 20:30>Completed*
16674686/29/2024 23:046/30/2024 8:38>Completed*
16674696/30/2024 0:106/30/2024 0:35>Completed*
16674706/30/2024 7:126/30/2024 8:38>Completed*
16674716/30/2024 14:056/30/2024 18:31>Closed
16674746/30/2024 23:127/1/2024 0:31>Closed
16674757/1/2024 0:067/1/2024 7:35>Closed
16674767/1/2024 16:017/1/2024 16:30>Closed
16674777/1/2024 23:057/1/2024 23:37>Closed
16674787/2/2024 11:51 Scheduled
16674797/2/2024 13:06 Scheduled
16674807/2/2024 16:597/2/2024 17:33>Closed
16674817/3/2024 9:34 Scheduled
16674827/3/2024 14:15 Scheduled
16674837/3/2024 20:067/3/2024 20:31>Closed
16674847/3/2024 23:087/4/2024 13:31>Closed
16674857/4/2024 7:017/4/2024 7:35>Closed
16674867/4/2024 7:117/4/2024 7:35>Closed
16674877/4/2024 14:597/4/2024 17:30>Closed
16674887/4/2024 15:027/4/2024 16:30>Closed
16674897/4/2024 16:087/4/2024 16:30>Closed
16674907/4/2024 19:017/4/2024 19:30>Closed
16674917/5/2024 0:567/5/2024 13:33>Closed
16674927/5/2024 15:007/6/2024 21:31>Completed*
16674937/5/2024 16:017/5/2024 16:30>Completed*
16674947/5/2024 21:587/5/2024 22:30>Completed*
16674957/6/2024 0:017/6/2024 0:30>Completed*
16674967/6/2024 8:107/6/2024 9:30>Completed*
16674977/6/2024 12:057/6/2024 12:31>Completed*
16674987/6/2024 14:057/6/2024 14:30>Completed*
16674997/6/2024 16:007/6/2024 16:35>Completed*
16675007/6/2024 20:047/7/2024 0:35>Completed*
16675017/7/2024 7:077/7/2024 7:30>Completed*
16675027/7/2024 9:047/7/2024 9:36>Completed*
16675037/7/2024 13:007/7/2024 13:30>Completed*
16675047/7/2024 13:057/7/2024 13:30>Completed*
16675057/7/2024 17:057/7/2024 17:30>Completed*
16675227/9/2024 17:067/9/2024 17:40>Closed
16675237/9/2024 20:077/9/2024 20:30>Closed
16675247/10/2024 15:047/10/2024 15:34>Closed
16675257/10/2024 15:057/10/2024 15:34>Closed
16675267/10/2024 17:067/10/2024 17:30>Closed
16676317/29/2024 8:067/29/2024 8:31>Closed
16676327/29/2024 12:00 Scheduled
16676337/29/2024 12:037/30/2024 7:30>Closed
16676347/30/2024 9:11 New*
16676357/30/2024 10:44 New*
16676367/30/2024 11:24 Scheduled
16676377/30/2024 12:03 Scheduled
16676387/30/2024 12:41 Scheduled
16676397/30/2024 13:16 New*
16676407/30/2024 13:19 New*
16676417/30/2024 16:56 In Progress
16676427/30/2024 16:57 Scheduled
16676437/30/2024 17:32 New*
16676447/31/2024 7:11 Scheduled
16676457/31/2024 10:09 New*
16676467/31/2024 11:13 Assigned
16676477/31/2024 12:32 User Has Responded
16676487/31/2024 13:047/31/2024 14:34>Closed
16676497/31/2024 15:28 In Progress
16676507/31/2024 16:25 New*
16676517/31/2024 16:53 New*
16676527/31/2024 17:037/31/2024 17:31>Closed
16676538/1/2024 11:048/1/2024 21:32>Completed*
16676548/1/2024 12:088/1/2024 12:31>Completed*
16676558/2/2024 11:528/2/2024 11:54>Closed
16676568/2/2024 17:088/2/2024 17:30>Completed*
16676578/2/2024 22:068/4/2024 15:30>Completed*
16676588/3/2024 7:068/4/2024 9:30>Completed*
16676598/3/2024 8:048/3/2024 8:36>Completed*
16676608/3/2024 9:068/3/2024 9:30>Completed*
16676618/3/2024 11:588/3/2024 12:30>Completed*
16676628/3/2024 16:098/3/2024 17:31>Completed*
16676638/3/2024 19:078/3/2024 20:35>Completed*
16676648/4/2024 13:078/4/2024 13:30>Completed*
16676658/4/2024 15:048/4/2024 15:30>Completed*
16676668/4/2024 20:068/4/2024 21:30>Completed*
16676678/4/2024 23:078/4/2024 23:30>Completed*
16676688/5/2024 7:068/5/2024 8:31>Completed*
16676698/5/2024 11:018/5/2024 15:32>Completed*
16676708/5/2024 11:018/6/2024 14:31>Completed*
16676718/5/2024 15:068/5/2024 15:32>Completed*
16676728/5/2024 17:038/5/2024 17:30>Completed*
16676738/5/2024 17:098/5/2024 17:30>Completed*
16676748/6/2024 16:568/6/2024 17:30>Completed*
16676758/7/2024 18:028/7/2024 19:30>Completed*
16676768/7/2024 21:018/7/2024 22:34>Completed*
16676778/8/2024 10:57 Waiting on User
16676788/8/2024 15:46 New*
16676798/8/2024 20:598/8/2024 23:32>Completed*
16676808/9/2024 9:558/9/2024 12:31>Completed*
16676818/9/2024 14:45 New*
16676828/9/2024 16:058/9/2024 16:30>Completed*
16676838/9/2024 21:558/10/2024 0:32>Completed*
16676848/10/2024 6:598/10/2024 21:31>Completed*
16676858/10/2024 11:078/10/2024 21:32>Completed*
16676868/10/2024 19:068/10/2024 19:30>Completed*
16676878/10/2024 20:49 In Progress
16676888/10/2024 22:048/10/2024 22:31>Completed*
16676948/12/2024 10:26 Waiting on Vendor
16676958/12/2024 12:06 New*
16676968/12/2024 12:088/12/2024 13:30>Completed*
16676978/12/2024 14:30 Scheduled
16677468/19/2024 19:588/19/2024 20:37>Completed*
16677528/21/2024 14:23 New*
16677538/21/2024 15:498/21/2024 16:30>Completed*
16677548/21/2024 16:588/21/2024 18:30>Completed*
16677558/21/2024 19:068/21/2024 21:30>Completed*
16677568/21/2024 20:31 In Progress
16677578/21/2024 21:058/22/2024 0:31>Completed*
16677588/21/2024 22:518/21/2024 23:30>Completed*
16677598/22/2024 1:00 In Progress
16677608/22/2024 7:108/22/2024 7:30>Completed*
16677618/22/2024 9:35 New*
16677628/23/2024 0:018/23/2024 0:31>Completed*
16677638/23/2024 7:108/23/2024 7:32>Completed*
16677648/23/2024 15:38 Scheduled
16677658/23/2024 15:508/23/2024 16:34>Completed*
16677668/23/2024 23:128/24/2024 13:31>Completed*
16677678/24/2024 15:038/24/2024 18:31>Completed*
16677688/24/2024 16:088/25/2024 10:30>Completed*
16677698/24/2024 23:498/25/2024 9:30>Completed*
16677708/25/2024 0:008/25/2024 0:30>Completed*
16677718/25/2024 7:078/25/2024 10:30>Completed*
16677728/25/2024 12:558/25/2024 17:30>Completed*
16677738/25/2024 13:158/25/2024 15:30>Completed*
16677748/26/2024 10:45 New*
16677758/26/2024 11:10 Waiting on User
16677768/26/2024 15:11 New*
16677778/27/2024 6:498/27/2024 7:34>Completed*
16677788/27/2024 8:54 New*
16677798/27/2024 14:52 Scheduled
16677808/27/2024 15:078/27/2024 15:31>Completed*
16677818/27/2024 15:26 Scheduled
16677828/27/2024 19:058/27/2024 20:31>Completed*
16677838/28/2024 6:558/28/2024 7:30>Completed*
16677848/28/2024 8:52 In Progress
16677858/28/2024 9:42 In Progress
16677868/28/2024 11:558/28/2024 13:30>Completed*
16677878/28/2024 12:078/29/2024 12:30>Completed*
16677888/28/2024 12:30 Waiting on User
16677898/28/2024 23:108/29/2024 0:30>Completed*
16677908/29/2024 8:54 Scheduled
16677918/29/2024 9:01 Scheduled
16678028/30/2024 17:40 New*
16678038/30/2024 18:12 New*
16678048/30/2024 20:578/30/2024 21:30>Completed*
16678058/31/2024 6:08 New*
16678068/31/2024 7:29 New*
16678078/31/2024 8:058/31/2024 8:30>Completed*
16678088/31/2024 8:53 New*
16678098/31/2024 14:588/31/2024 15:30>Completed*
16678108/31/2024 16:088/31/2024 17:30>Completed*
16678118/31/2024 18:059/1/2024 18:30>Completed*
16678128/31/2024 19:088/31/2024 19:30>Completed*
16678138/31/2024 20:588/31/2024 22:30>Completed*

 

Thank you again

lbendlin_0-1726500318705.png

 

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.

ajdm2007_0-1727123373922.png

 

 

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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors