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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Sparkeltje
Frequent Visitor

How to translate SQL to DAX && 'table'[PK_Inv#] like '_____'

Hello guys,
 
Hope you can help me, I'm looking for the dax equivelament for like in SQL, in this case I want DAX only to CALCULATE if investments are with 5 positions. 

Investments =

VAR FINYEAR = SELECTEDVALUE('table'[Financial_Year])

RETURN
CALCULATE(SUMX(FILTER('table',
'table'[Source] = "PL"
-- && 'table'[PK_Inv#] like '_____'
&& 'table'[Type] IN {"1", "2"}),
'table'[costs]) ,

'table'[Financial_Year] = FINYEAR,
'table'[Financial_Year])
 
---
Thank you! 
1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Sparkeltje 

You can use LEN function to get the investments with 5 positions.

 

InvInvestments =

VAR FINYEAR =

    SELECTEDVALUE ( 'table'[Financial_Year] )

RETURN

    CALCULATE (

        SUMX (

            FILTER (

                'table',

                'table'[Source] = "PL"

                    && LEN ( 'table'[PK_Inv#] ) = 5

                    && 'table'[Type] IN { "1", "2" }

            ),

            'table'[costs]

        ),

        'table'[Financial_Year] = FINYEAR,

        'table'[Financial_Year]

)

 

For more details about this function, you can refer LEN.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? 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

5 REPLIES 5
v-cazheng-msft
Community Support
Community Support

Hi @Sparkeltje 

Is your problem solved?

 

Best Regards

Caiyun Zheng

Yes. Thank you! 

v-cazheng-msft
Community Support
Community Support

Hi @Sparkeltje 

You can use LEN function to get the investments with 5 positions.

 

InvInvestments =

VAR FINYEAR =

    SELECTEDVALUE ( 'table'[Financial_Year] )

RETURN

    CALCULATE (

        SUMX (

            FILTER (

                'table',

                'table'[Source] = "PL"

                    && LEN ( 'table'[PK_Inv#] ) = 5

                    && 'table'[Type] IN { "1", "2" }

            ),

            'table'[costs]

        ),

        'table'[Financial_Year] = FINYEAR,

        'table'[Financial_Year]

)

 

For more details about this function, you can refer LEN.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Sparkeltje
Frequent Visitor

Problem is that calculation is needed only from the 2 investment numbers that have 5 positions. I don't get that working with contains or containsstring.

10624-VA06-360

10521-VA05-360

10500-VA04-60

11269

11281

10538-VA02-180

 

Jihwan_Kim
Super User
Super User

Hi, @Sparkeltje 

Please try to use contains or containsstring DAX function.

Or, please have a look at the below article, if that is what you needed.

 

https://www.sqlbi.com/articles/from-sql-to-dax-string-comparison/

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.