Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

SUM Filter Text

Hi All,

 

I am trying to create a measure to sum one column then filter that sum based upon text values in another column.

 

(The text filter will have to be based on a "or" function, not "and") (This has to be done in DAX as it will be part of another measure further down the line).

 

So far I have tried

 

Site Mileage = CALCULATE(SUM(TrakM8[Distance (mi)]), TrakM8[Start Date] = "10th Street", "11th Street", "12th Street", "13th Street", "14th Street") 
 
But this is not working.
 
Any ideas on how to resolve this?
 
Many thanks,
  • Yes you can add like below

    Site Mileage =
    CALCULATE (
        SUM ( TrakM8[Distance (mi)] ),
        TrakM8[Start Date]
            IN { "10th Street", "11th Street", "12th Street", "13th Street", "14th Street" },
    TrackM8[somecolumn] IN {somevalue1,somevalue2,somevalueN}
    )

     

9 Replies

  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi Anonymous ,

     

    It would be helpful to answer more specifically if you could share some sample data with expected output. Based on what you are trying for that, below would be ideal code:-

    Site Mileage =
    CALCULATE (
        SUM ( TrakM8[Distance (mi)] ),
        TrakM8[Start Date]
            IN { "10th Street", "11th Street", "12th Street", "13th Street", "14th Street" }
    )

     

    Thanks,

    Samarth

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, 

       

      Many thanks for your response.

       

      I copied your DAX word for word and recieved no errors but when placing into into a table or card visual I recieve the below error.

       

      Also how would I ammend the DAX to allow for text filters from two different columns?

       

      Cheers,

       

      Elliot 

      • Samarth_18's avatar
        Samarth_18
        Community Champion

        Is it possible for you share sample data with expected output or sample file after removing confidencial data??