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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
mariahMC
Helper I
Helper I

Previous month of last month in dataset

I am trying to create a KPI visual that shows the sum of the last month in the dataset compared to the sum of the previous month (of the last month in the data set). To do this, I created a measure to calculate the previous month total:

 

PreviousMonth = CALCULATE(SUM('CompPayments'[Payment Amount]), PREVIOUSMONTH('CompPayments'[Payment Received Date].[Date]))

 

However, the KPI card shows blank because it's calculating based on current month but I will never have data for the current month.

mariahMC_0-1729634999047.png

 

For example, we are in October but the last month in my dataset is September so I need it to show total of September with the target "goal" being the sum of August. When November hits and I update the dataset, I need it to show October vs September, etc.

 

 

 

1 ACCEPTED SOLUTION

Hi,

I suggest to create a date table.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi,

Without seeing your semantic model, I can't be entirely certain, but it seems likely that the latest month is being defined in your model using the TODAY() function in a measure.

If that’s the case, I recommend using the last date from the fact table instead of TODAY() to define the latest month. This way, the latest month will always display the data (no blank), allowing you to compare it with the previous month.

Hope this helps!


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks! I created a date table and filtered by maxdate and that seems to work for now. 

 

PrevMTD =
var maxdate = EOMONTH(TODAY(),-2)
RETURN
CALCULATE(
    SUM('CompPayments'[Payment Amount]),
    FILTER(ALL('Calendar'),'Calendar'[Date] <= maxdate),
    DATEADD('Calendar'[Date],-1,MONTH))
 
mariahMC_0-1730124769162.png

 

 

Right now I am only using one data source in my model as practice since I am new to power bi. Eventually I will add additional sources to my model. Do I need to create a date table?

Hi,

I suggest to create a date table.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi @mariahMC ,

Please update the formula of measure [PreviousMonth] as below and check if it can return the expected result...

PreviousMonth =
CALCULATE (
    SUM ( 'CompPayments'[Payment Amount] ),
    PREVIOUSMONTH ( 'CompPayments'[Payment Received Date] )
)

vyiruanmsft_0-1729650489343.png

Best Regards

I made this change and it gives me September total, but the Goal is blank and not calculating the total of August 

mariahMC_1-1729699011204.png

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.