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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dancarr22
Helper V
Helper V

FILTER in DAX measure not working properly -- when there are 2 filters

Hello,

 

I am using Power BI/DAX to calculate linked returns for a portfolio.

We have 2 different return fields -- one for daily return and one for monthly returns.

Theoretically, they should return the same value.

The DAX formulas are almost exactly the same except the MTD has an additional FILTER -- where IsMTD=TRUE

 

THIS WORKS

msr_LinkedReturn_Daily = VAR DATECOL= MAX(AccountReturn[AccountReturn_AsOfDate])
RETURN (CALCULATE(
        PRODUCT(
          AccountReturn[calc_Return_Daily]
            ),
            FILTER(
               AccountReturn,
                AccountReturn[AccountReturn_AsOfDate]<=DATECOL )
               )-1)

 

THIS DOES NOT WORK

msr_LinkedReturn_MTD = VAR DATECOL= MAX(AccountReturn[AccountReturn_AsOfDate])
RETURN (CALCULATE(
        PRODUCT(
          AccountReturn[calc_Return_MTD]
            ),FILTER(AccountReturn,AccountReturn[IsLastDayOfMonth]=TRUE),
            FILTER(
               AccountReturn,
                AccountReturn[AccountReturn_AsOfDate]<=DATECOL )
               )-1)

 The only real difference between these 2 formulas (besides a different field value being used) is the MTD has 2 filter fields -- the daily only has one.  The additional filter in MTD is: FILTER(AccountReturn,AccountReturn[IsLastDayOfMonth]=TRUE),

 

The MTD does sometimes work when I only rollup for a few portfolios -- but when I select more than 3 or 4 everything gets set to -100%.

 

Any help you can offer is greatly appreciated.

 

Thanks,

Dan

1 ACCEPTED SOLUTION

Hi Lydia,

 

Thanks for your response.

The field was a boolean (true/false).  I found the error was in setting the variable at the start of the function.  That was not required as that filter was already applied by defualt.

So, this issue has been resolved.  Was user error.

 

Thanks,

Dan

 

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@dancarr22,

What is the data type of IsLastDayOfMonth field? Is it text or True/False? You need to change the additional FILTER formula to the following if it is text:

FILTER(AccountReturn,AccountReturn[IsLastDayOfMonth]="TRUE")

If the above step doesn't help,  please share sample data of the AccountReturn table here.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Lydia,

 

Thanks for your response.

The field was a boolean (true/false).  I found the error was in setting the variable at the start of the function.  That was not required as that filter was already applied by defualt.

So, this issue has been resolved.  Was user error.

 

Thanks,

Dan

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.