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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Djotis
Regular Visitor

Sum of rows referencing another column's values when datatype is text

Hello everyone, 

I have a table that looks like below. I need to write a measure that calculates the sum of values from the Value column based on the values AM35 up to AM41 in the Field Code column, hence the returned result should be 72. My additional problem is that the Value column is of datatype text because it contains mixed text and numbers therefore I cannot change the datatype. Any suggestions would be appreciated.

Djotis_0-1676475903422.png

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Djotis 

 

You can add a custom column with below code to get only the number values. For other text type values, return null in the custom column. Then convert this new column to Number type. You can then create a measure with SUM function to get the sum of these values. 

if Number.From(Text.AfterDelimiter([Field Code],"AM")) >= 36 and Number.From(Text.AfterDelimiter([Field Code],"AM")) <= 41 then [Value] else null

vjingzhang_0-1676600872608.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Djotis 

 

You can add a custom column with below code to get only the number values. For other text type values, return null in the custom column. Then convert this new column to Number type. You can then create a measure with SUM function to get the sum of these values. 

if Number.From(Text.AfterDelimiter([Field Code],"AM")) >= 36 and Number.From(Text.AfterDelimiter([Field Code],"AM")) <= 41 then [Value] else null

vjingzhang_0-1676600872608.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Djotis
Regular Visitor

Sorry the expected result should be 135. Made a mistake with the calculation.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors