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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
abhay03
Helper I
Helper I

sum of values in a Text type field

I have a table which has some string and some numeric values. Becuase of string values the type of the field is Text.

 

SeriesFilesValue
IAabc
IAabc
IB2
IB2
IC3
IC3
IIAabc
IIB5
IIB5
IIC3
IIC3


I want to create a measure that filters out text fields and calculates the sum of Distinct values by Files group by Series for numeric values. So here the expected outcome would be:

 

SeriesCountExplanation
I5Distinct of B + Distinct of C (2+3)
II8Distinct of B + Distinct of C (5+3)
1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@abhay03

 

Hi, try this:

 

To a better explanation i create columns :

 

1: Two calculated Columns:

 

IsText = IF(ISERROR(VALUE(Table1[Value])),"Text","Number")

ValuetoNumber = IF(Table1[IsText]="Number",VALUE(Table1[Value]))

 

2. A measure to SUM

 

Measure =
SUMX (
    SUMMARIZE (
        'Table1',
        'Table1'[Series],
        'Table1'[Files],
        "ValueX", AVERAGE ( Table1[ValuetoNumber] )
    ),
    [ValueX]
)

Image.png

Regards

 

Victor

Lima - Peru

 

 




Lima - Peru

View solution in original post

2 REPLIES 2
Vvelarde
Community Champion
Community Champion

@abhay03

 

Hi, try this:

 

To a better explanation i create columns :

 

1: Two calculated Columns:

 

IsText = IF(ISERROR(VALUE(Table1[Value])),"Text","Number")

ValuetoNumber = IF(Table1[IsText]="Number",VALUE(Table1[Value]))

 

2. A measure to SUM

 

Measure =
SUMX (
    SUMMARIZE (
        'Table1',
        'Table1'[Series],
        'Table1'[Files],
        "ValueX", AVERAGE ( Table1[ValuetoNumber] )
    ),
    [ValueX]
)

Image.png

Regards

 

Victor

Lima - Peru

 

 




Lima - Peru

Thanks @Vvelarde,

 

you are just missing a comma after SUMMARIZE function in the measure. Your solution worked perfectly for me.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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