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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
KevinRDynasoft
Frequent Visitor

Same Period Last Month with another measure

Hi there,

 

I have a Total Income and Total Deduction DAX measures and they work fine but I'm trying to show the same values compared to last month.

I'm using these formulas for totals:

Total Income= CALCULATE(SUM('Payroll Report'[Total]),FILTER('Payroll Report','Payroll Report'[Type]=="Income"))
Total Deduction= CALCULATE(SUM('Payroll Report'[Total]),FILTER('Payroll Report','Payroll Report'[Type]=="Deduction"))
------------------------------------------------------------------------------------------------------------------------------------------------
And these formulas for prev month:
Prev Month Income = CALCULATE([Total Income], DATEADD('Payroll Report'[Date], -1, MONTH))
 
If i insert a table that shows date, total income and prev month income, I can see that prev month income has no data.
 
It's not a relationship problem because my 'Date' is column inside my payroll report. 'Total' is formatted to currency. 'Total Income' is also formatted to currency.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

For time intelligence prefer using date calendar table

Prev Month Income = CALCULATE([Total Income], DATEADD('adte'[Date], -1, MONTH))
or

Prev Month Income = CALCULATE([Total Income], datesmtd(DATEADD('adte'[Date], -1, MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

For time intelligence prefer using date calendar table

Prev Month Income = CALCULATE([Total Income], DATEADD('adte'[Date], -1, MONTH))
or

Prev Month Income = CALCULATE([Total Income], datesmtd(DATEADD('adte'[Date], -1, MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

HotChilli
Super User
Super User

Test the dateadd clause to see if it's returning blanks.

Yes. It's returning blank

Hopefully it's sorted now.  The dates that DATEADD returns must already exist in the date column you use otherwise it returns blank.  That's why a date table works (This can still return blanks for the same reason but not if you set the date table up properly)

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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