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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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