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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

SUM, Filter by Two Columns text values

Hi All,

 

I am trying to perform a calculation where I do the following

 

SUM column 1

Filter by column 2 (multiple text values)

and

Filter by column 3 (multiple text values)

Can this be done in DAX? Visaul level filtering is not an option.
1 ACCEPTED SOLUTION

Hi @Anonymous 

 

Try this measure:

Measure =
VAR _filter_from_Start =
    FILTER(
        'Table',
        [Start Street] = "1st street"
            || [Start Street] = "2nd street"
            || [Start Street] = "10th street"
    )
VAR _filter_from_End =
    FILTER(
        _filter_from_Start,
        [End Street] = "2nd street"
            || [End Street] = "3rd street"
            || [End Street] = "8th street"
    )
RETURN
    SUMX( _filter_from_End, [Distance Miles] )

But the conditions is too long or in your data, is that possible to use start street not equal waterloo road?

If is , filter with the condition  

[Start Street]<>”waterloo road”

 

Best Regards

Community Support Team _ chenwu zhu

 

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

6 REPLIES 6
jppv20
Solution Sage
Solution Sage

Hi @Anonymous ,

 

You can create this measure:

MilesDisctance = CALCULATE(SUM('Table'[Distance Miles]),'Table'[Start Street]="1st street"||'Table'[Start Street]="2nd street"||'Table'[Start Street]="10th street",'Table'[End Street]="2nd street"||'Table'[End Street]="3rd street"||'Table'[End Street]="8th street")
 
Jori
 
If I answered your question, please mark it as a solution to help other members find it more quickly.
Anonymous
Not applicable

Thanks. I have tried this measure but it seems to be doing the following

 

SUM of mileage for column 'Start Street' with text filters + SUM of mileage for column 'End Street' with text filters.

 

Instead it should be doing SUM of mileage for columns 'Start Street' and 'End Street' where both columns meet the text filter criteria.

 

Hi @Anonymous ,

 

I don't think I completely understand what you mean. Could you explain a bit more what's nog working correctly? 

jppv20
Solution Sage
Solution Sage

Hi @Anonymous ,

 

Could you provide some example data and expected output?

 

Anonymous
Not applicable

Hi,

 

Please see the requested below.

 

Distance MilesStart StreetEnd Street
51st street2nd street
61st streetwaterloo road
82nd streetwaterloo road
3waterloo road3rd street
6510th street8th street

 

SUM of column 'Distance Miles;

Filter column 'Start Street' to = 1st street, 2nd street, 10th street 

Filter column 'End Street' to = 2nd street, 3rd street, 8th street

 

Expexted outcome = 70

 

Hope this helps

Hi @Anonymous 

 

Try this measure:

Measure =
VAR _filter_from_Start =
    FILTER(
        'Table',
        [Start Street] = "1st street"
            || [Start Street] = "2nd street"
            || [Start Street] = "10th street"
    )
VAR _filter_from_End =
    FILTER(
        _filter_from_Start,
        [End Street] = "2nd street"
            || [End Street] = "3rd street"
            || [End Street] = "8th street"
    )
RETURN
    SUMX( _filter_from_End, [Distance Miles] )

But the conditions is too long or in your data, is that possible to use start street not equal waterloo road?

If is , filter with the condition  

[Start Street]<>”waterloo road”

 

Best Regards

Community Support Team _ chenwu zhu

 

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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