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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Diego-mx
Advocate I
Advocate I

Combine TREATAS filters in FILTER function

In a CALCULATE expression I can add different filters with commas. 

 

TotalSells = CALCULATE( SUM(Merchandise[prices]), 
    Merchandise[was_sold], 
    TREATAS( VALUES(Calendar[date]), Merchandise[sold_date])
)

Now I need to use the filters inside an X-function, from which the parameter changes. 

QuickSells = AVERAGEX( 
    FILTER(Merchandise, 
        [was_sold], 
        TREATAS( VALUES(Calendar[date]), Merchandise[sold_date])), 
    Merchandise[days_to_sell] <= 10
)

This throws an error since FILTER only takes one filter.  
If they were all logical, I could do mix them with & operators.  
Since I have TREATAS, it gets more difficult. 
Does someone know how to do this?

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Diego-mx,

 

I can't get the calculate logic from your formula, but I think it is impossible to modify teratas function to add conditions into function.

 

Based on my understanding, treatas function is similar as 'in' operate. Maybe you can try to use following formula if it suitable for your requirement:

QuickSells =
AVERAGEX (
    FILTER (
        ALLSELECTED ( Merchandise ),
        Merchandise[was_sold] = TRUE ()
            && Merchandise[sold_date] IN VALUES ( Calendar[date] )
            && Merchandise[days_to_sell] <= 10
    ),
    Merchandise[prices]
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

The logic is that I want to find what proportion where sold in less than 10 days. 
So the condition [sold_days] <= 10, gets turned into 1 and 0 and averaged.  

Using ... IN VALUES(Calendar[date]) was helpful, but now the logical-to-numeric is not working.  

I'll keep trying. 

 

HI @Diego-mx,

 

Can you please share some sample data with expect result to help us clarify your scenario?

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.