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
adriansuteu
Advocate I
Advocate I

Filter measure based on related table column value

Hello.

 

I have the following situation: I have a measure that needs to be filtered based on the column value from a related table. More specifically I want to exclude the amount of money from invoice numbers that contain "ctr".  I know that there are other ways of doing this but I can not use the filters on the report/this page/this visual section because the user will lately be able to choose between this new measure and another measure to show in the table. I can not use columns instead of measure because this measure is the source of a lot of calculations and it is also another variable measure.

 

The source measure looks like this:

Amount Left (Selected) =
VAR VAT = [Amount Left Artif with VAT (for table) aged rec]
VAR woVAT = [Amount Left Artif (for table) aged rec]
VAR SelectedValue = MIN(VAT_Filter[Id])
RETURN
IF (HASONEVALUE(VAT_Filter[Value]),
    SWITCH (SelectedValue,
        1, VAT,
        2, woVAT))

 

After selecting this the user is supposed to select another indicator on the same system. With or without Invoices (from a related table) that contain "ctr" in invoice number (string column).

 

I was trying to do this but it does not work:

Amount without Contracts = CALCULATE([Amount Left (Selected)],FILTER(Courses,Courses[Invoice] <> "%ctr%"))
 
Can you please help me with the DAX so I can filter an already established measure based on a column in a related table?
 
Thank you,
 
1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

Hi, @adriansuteu 

Just add just your formula as below:

Amount without Contracts = CALCULATE([Amount Left (Selected)],FILTER(Courses,SEARCH("ctr",Courses[Invoice],1,0)=0))

or

Amount without Contracts 2 = CALCULATE([Amount Left (Selected)],FILTER(Courses,FIND("ctr",Courses[Invoice],1,0)=0))

Result:

1.JPG

 

Regards,

Lin

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

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

Hi, @adriansuteu 

Just add just your formula as below:

Amount without Contracts = CALCULATE([Amount Left (Selected)],FILTER(Courses,SEARCH("ctr",Courses[Invoice],1,0)=0))

or

Amount without Contracts 2 = CALCULATE([Amount Left (Selected)],FILTER(Courses,FIND("ctr",Courses[Invoice],1,0)=0))

Result:

1.JPG

 

Regards,

Lin

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

Power Bi has a search function

https://community.powerbi.com/t5/Desktop/LIKE-function-in-a-measure/td-p/192651

https://docs.microsoft.com/en-us/dax/search-function-dax

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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.