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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Reddyp
Helper I
Helper I

need help in DAX query

Hi, I have a SQL query but need to change this to DAX, can you please help 
Store SIT => sum(qty) where Location like ‘%-T’

Story: I need to sum qty from Excel1 and I need to search location column where data ends with -T (example W0032-T) in Excel2

 

1 ACCEPTED SOLUTION

@Reddyp Update it as below:-

Column =
IF (
    YEAR ( 'Sheet1'[Date] ) = 2021
        && 'Sheet1'[cost_amount_physical] <> BLANK () && related('Sheet2'[location]) = "Auckland",
    'Sheet1'[cost_amount_physical],
    'Sheet1'[Cost_amount_posted]
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Hi @Reddyp ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept a helpful reply as the solution to make the thread closed. More people will benefit from it.

Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Best Regards,
Eyelyn Qin

Reddyp
Helper I
Helper I

@Samarth_18 another question, help me with the syntax 

 if date = '2021' then use cost_amount_physical otherwise use Cost_amount_posted

 




    Desired Result
ProductDatecost_amount_physicalCost_amount_postedStore Cost
Cycle01-01-2021$10 $10
Bike01-01-2021 $22$22

@Reddyp , Create a column as below:-

Column =
IF (
    YEAR ( 'Table (2)'[Date] ) = 2021
        && 'Table (2)'[cost_amount_physical] <> BLANK (),
    'Table (2)'[cost_amount_physical],
    'Table (2)'[Cost_amount_posted]
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

@Samarth_18 @johnt75 
Super, this works 
if date = '2021' then use cost_amount_physical otherwise use Cost_amount_posted

Column =
IF (
    YEAR ( 'Table (2)'[Date] ) = 2021
        && 'Table (2)'[cost_amount_physical] <> BLANK (),
    'Table (2)'[cost_amount_physical],
    'Table (2)'[Cost_amount_posted]
)


 need to add one more thing 
if date = (Sheet 1)'2021' then use (Sheet1)cost_amount_physical otherwise use (Sheet1)Cost_amount_posted and filter by (Sheet2)location = "Acukland"

@Reddyp Update it as below:-

Column =
IF (
    YEAR ( 'Sheet1'[Date] ) = 2021
        && 'Sheet1'[cost_amount_physical] <> BLANK () && related('Sheet2'[location]) = "Auckland",
    'Sheet1'[cost_amount_physical],
    'Sheet1'[Cost_amount_posted]
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

johnt75
Super User
Super User

You may get better performance if you create a new column in Power Query which uses Text.End to check whether the string ends in -T or not. You can then use this new column as a filter for your calculations and it isn't having to do a text comparison each time.

Samarth_18
Community Champion
Community Champion

Hi @Reddyp ,

 

You could try like this:-

Store SIT =
CALCULATE (
    SUM ( excel1[qty] ),
    FILTER ( excel2, CONTAINSSTRING ( excel2[Location], "-T" ) )
)

Note- I am considering you have relation between both loaded excel sheet.

 

BR,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

@Samarth_18 thank you so much, yes I have relation between 2 excel sheets 
i ran this query and the result was -2, i dont understand this (but checking for issue)

is this query "sum" all colums where text ends with "-T" (example: W0019-T, Woo26-T) and dont sum text without "-T" (example: W0094, W0024) ?

@Reddyp Yes it will sum qty column where location contains "-T".

It would be helpful if you could share the sample data in text format with sample data.

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.