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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
vijay273162
Helper III
Helper III

TREATAS

HI All,

Need to find previousmonth sales using TREATAS 

 

below is the sample code......

 

Sales in previous month =
VAR result1  =
CALCULATE(SUM(Order[sales]),
          TREATAS (VALUES ('delivery-date-table'[Date]),
                         'Order-datetable'[date] )
)
 
var result2 =
CALCULATE(a,
                  PREVIOUSMONTH( 'Order-datetable'[date] )
return
result2
 
the problem is I can move the filter from delivery date table to order date table ( which has relationship with sales table)
but when I try to find the previousmonth data ( for delivery date table ), the treatas function can't help me here.
 
 
How to use TREATAS and PREVIOUSMONTH in calculated function ?
 
1 ACCEPTED SOLUTION

Hi, @vijay273162 

TREATAS  is used to apply the result of a table expression as filters to columns from an unrelated table.

You should make sure that here should be no physical relationship  between  Table "Orders" and Table "Delivery Dates Table".

 

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@vijay273162 , You should use date table, Try like

 

CALCULATE(SUM(Order[sales]),
TREATAS (PREVIOUSMONTH( 'Order-datetable'[date] ),
'Order-datetable'[date] )
)

or


CALCULATE(SUM(Order[sales]),
TREATAS (PREVIOUSMONTH( 'Date'[date] ),
'Order-datetable'[date] )
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

If I use PREVIOUSMONTH in TREATAS, then..... I don't get any result in my table matrxi below.

 

vijay273162_0-1649842165886.png

 

So, I need to move the filter from delivery date table to order date table - at the sametime find the previousmonth data.

Hi, @vijay273162 

TREATAS  is used to apply the result of a table expression as filters to columns from an unrelated table.

You should make sure that here should be no physical relationship  between  Table "Orders" and Table "Delivery Dates Table".

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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