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
gbernardes
Frequent Visitor

Compare periods until same time last month/year

Hello!

 

I need to compare my sells last month and last year but only until the same time as now.

 

Ex: now is 02may22 10hA.M. -> I need to compare until 02apr22 until 10A.M. / 02may21 until 10A.M.

 

Any idea how can I do this? 

PS: dateadd considers all the day, not until the same time

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@gbernardes , Assuming you need from start of month

 

 

This month =
var _max = now()
var _min = eomonth(datevalue(_max) ,-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[DateTime] >=_min && 'Table'[DateTime] <= _max) )

 

 

Last one Month Now =
var _maxDt = date(year(today()),Month(today())-1,day(Today()))
var _max = _maxDt+ timevalue(now())
var _min = eomonth(_maxDt,-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[DateTime] >=_min && 'Table'[DateTime] <= _max) )


Last one Year SM Now =
var _maxDt = date(year(today())-1,Month(today()),day(Today()))
var _max = _maxDt+ timevalue(now())
var _min = eomonth(_maxDt,-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[DateTime] >=_min && 'Table'[DateTime] <= _max) )

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@gbernardes , Assuming you need from start of month

 

 

This month =
var _max = now()
var _min = eomonth(datevalue(_max) ,-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[DateTime] >=_min && 'Table'[DateTime] <= _max) )

 

 

Last one Month Now =
var _maxDt = date(year(today()),Month(today())-1,day(Today()))
var _max = _maxDt+ timevalue(now())
var _min = eomonth(_maxDt,-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[DateTime] >=_min && 'Table'[DateTime] <= _max) )


Last one Year SM Now =
var _maxDt = date(year(today())-1,Month(today()),day(Today()))
var _max = _maxDt+ timevalue(now())
var _min = eomonth(_maxDt,-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[DateTime] >=_min && 'Table'[DateTime] <= _max) )

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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.