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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.