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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NZCraig
Helper I
Helper I

Card to show last month and month before values

Hi,

 

I have a table shown below, which has a relationship to my date table 'Date'[Calendar Date] and I need to create some measures so that I can:

 

1. Show last months value only in a card or other visualisation - 18.62

2. Get the month before that value - 49.26 to use in another measure.

 

NZCraig_0-1636445675753.png

 

I have tried using  

Previous Month FO = CALCULATE ( SUM ( 'FOF'[fo_factor] ), DATEADD('Date'[Calendar Date], -1, MONTH) but I don't get the result I was expecting and I am pretty confident I'm not sure where to go from here :). Any help would be greatly appreciated.

Thanks

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@NZCraig , This should give you the correct result if you have selected oct -2021 in the slicer

Previous Month FO = CALCULATE ( SUM ( 'FOF'[fo_factor] ), DATEADD('Date'[Calendar Date], -1, MONTH) )

and last to last month

Previous Month FO = CALCULATE ( SUM ( 'FOF'[fo_factor] ), DATEADD('Date'[Calendar Date], -2, MONTH) )

 

Edit: These will work without a date slicer

This month Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),0) //today()
return
CALCULATE(SUM ( 'FOF'[fo_factor]) , FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

 

Last month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1) //today()
return
CALCULATE(SUM ( 'FOF'[fo_factor]), FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Last to last month Today =
var _min = eomonth(today(),-3)+1
var _max = eomonth(today(),-2) //today()
return
CALCULATE(SUM ( 'FOF'[fo_factor]) , FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw

All About Time Intelligence around Today: https://youtu.be/gcLhhxhXKEI

 

Why previousmonth does not give result when datesmtd is giving it: https://youtu.be/1KkoJehRVeg

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@NZCraig , This should give you the correct result if you have selected oct -2021 in the slicer

Previous Month FO = CALCULATE ( SUM ( 'FOF'[fo_factor] ), DATEADD('Date'[Calendar Date], -1, MONTH) )

and last to last month

Previous Month FO = CALCULATE ( SUM ( 'FOF'[fo_factor] ), DATEADD('Date'[Calendar Date], -2, MONTH) )

 

Edit: These will work without a date slicer

This month Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),0) //today()
return
CALCULATE(SUM ( 'FOF'[fo_factor]) , FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

 

Last month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1) //today()
return
CALCULATE(SUM ( 'FOF'[fo_factor]), FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Last to last month Today =
var _min = eomonth(today(),-3)+1
var _max = eomonth(today(),-2) //today()
return
CALCULATE(SUM ( 'FOF'[fo_factor]) , FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw

All About Time Intelligence around Today: https://youtu.be/gcLhhxhXKEI

 

Why previousmonth does not give result when datesmtd is giving it: https://youtu.be/1KkoJehRVeg

Thanks @amitchandak , This page won't have any slicers on it, and the other measure I am creating is a simple truth table to show if last months numbers were better or worse than the months previous, for use with a conditional formatted icon
Will these still work without the slicer? Thanks for the video links to btw :).

@NZCraig , if you do not have a slicer, and want to use time intelligence your option is to end the calendar on today or month end.

 

Or use the formula's like one I shared using today. They will work even without a selected date

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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