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

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

Reply
Eric-De
Frequent Visitor

FILTER and PREVIOUSMONTH function DAX , how to combine

Under powerautomate I used the PowerBI dataset to export some values under excell file, and I need to filter on the previousmonth only. 
For this I have create a calendar table to compare with the date closed under the table Tickets but when I implent the 
FILTER ( Tickets, Tickets[closed] = PREVIOUSMONTH(Calendar[Date])) 
instead of
FILTER ( Tickets, Tickets[closed] < DATE(YEAR(today()),MONTH(today()),1) && Tickets[closed] >= DATE(YEAR(today()),MONTH(today())-1,1) )
that return nothing
 
Here my script DAX who running
Can you help me to use corectly the PREVIOUSMONTH function for this ? 
 
// DAX Query
 
DEFINE
  VAR vType =   TREATAS({"CPU", "MEM","DISK"}, Tickets[Service])
 
EVALUATE
  SUMMARIZECOLUMNS
  (
    ROLLUPADDISSUBTOTAL
    (
      Tickets[Service], "Type", vType,
      TREATAS ( { "OK" }, Tickets[Status] ),
  FILTER( Tickets , RELATED(ServiceOffering[Service Offering]) ="TOP" ),
  FILTER ( Tickets, Tickets[closed] < DATE(YEAR(today()),MONTH(today()),1) && Tickets[closed] >= DATE(YEAR(today()),MONTH(today())-1,1) )
    ),
    "Total Qty", COUNT(Tickets[Target])
  )
 
ORDER BY
  [Type] DESC, [Service]
  
 
 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

 

DEFINE
  VAR vType =   TREATAS({"CPU", "MEM","DISK"}, Tickets[Service])
 
EVALUATE
  SUMMARIZECOLUMNS
  (
    ROLLUPADDISSUBTOTAL
    (
      Tickets[Service], "Type", vType,
      TREATAS ( { "OK" }, Tickets[Status] ),
  FILTER( Tickets , RELATED(ServiceOffering[Service Offering]) ="TOP" ),
  FILTER ( Dates, PREVIOUSMONTH(Dates[Date] )
    ),
    "Total Qty", COUNT(Tickets[Target])
  )

 

This assumes you have a Dates table in your data model and that it is joined to the Close Date.

View solution in original post

2 REPLIES 2
Eric-De
Frequent Visitor

Hello 

So need to create a table date for this 
CALENDAR (
    DATE ( YEAR ( MIN ( Tickets[Closed] ) ), 1, 1 ),
    DATE ( YEAR ( MAX ( Tickets[Closed] ) ), 12, 31 )
)
and because column containt date and time problably need o separate the date and time to group result by month
 
But in all case thank for your reply 
lbendlin
Super User
Super User

 

DEFINE
  VAR vType =   TREATAS({"CPU", "MEM","DISK"}, Tickets[Service])
 
EVALUATE
  SUMMARIZECOLUMNS
  (
    ROLLUPADDISSUBTOTAL
    (
      Tickets[Service], "Type", vType,
      TREATAS ( { "OK" }, Tickets[Status] ),
  FILTER( Tickets , RELATED(ServiceOffering[Service Offering]) ="TOP" ),
  FILTER ( Dates, PREVIOUSMONTH(Dates[Date] )
    ),
    "Total Qty", COUNT(Tickets[Target])
  )

 

This assumes you have a Dates table in your data model and that it is joined to the Close Date.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.