Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Add a column in M code and filter it on a condition based on a value in another table's column

Hi all, 

Is it possible to add a column in M code and filter that added column on a condition based on a value in a column in a related table?

For example, we want to add a column displaying all Products from the Product table that have a cost of 0. The cost column is in table Cost. So something like SELECT PRODUCT FROM PRODUCTS WHERE TOTAL_COST = 0; 

  • It si bad pratice to add M columns each time you need a filter.

     

    Use a DAX  measure instead ...

    Total cost = SUM('Fact costs'[Cost]) + 0
     
    Then filters  Total cost = 0

     

    Click here to download an example 

     

    Please click thumbs up and accept as solution

     

     

     

1 Reply

  • It si bad pratice to add M columns each time you need a filter.

     

    Use a DAX  measure instead ...

    Total cost = SUM('Fact costs'[Cost]) + 0
     
    Then filters  Total cost = 0

     

    Click here to download an example 

     

    Please click thumbs up and accept as solution