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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
efebo
Frequent Visitor

How can I count numbers and text in a text column in SharePoint Online?

Hi,

 

Help, please.

 

I have this requirement:

 

I have a text column with text and number values, and I need to count separately each type. Based on the image, I will have:

countOnlyNumbers.png

 

Can I do that?

 

Additionally....

 

If I a change data type within Power BI, this will affect my data stored in SharePoint Online? E.g.: If I change my text column format to integer within Power BI.

 

Thanks in advanced.

1 ACCEPTED SOLUTION

@efebo 

Following @AlexisOlson 's answer, you can try this

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table',NOT(ISERROR(VALUE('Table'[CONTENT])))&&NOT (ISBLANK('Table'[CONTENT]))))

1.PNG2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
v-cazheng-msft
Community Support
Community Support

Hi @efebo 

Is your problem solved? 

 

Best Regards

Caiyun Zheng

v-cazheng-msft
Community Support
Community Support

Hi @efebo 

You can make some changes to your dax formula as the following.

 

var Num=COUNTROWS(FILTER('Table','Table'[values]<>""&&NOT(ISERROR(VALUE('Table'[values])))))

var Txt=COUNTROWS(FILTER('Table','Table'[values]<>""&&ISERROR(VALUE('Table'[values]))))

 

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.

 

AlexisOlson
Super User
Super User

You could count the number of rows that can convert to a number without throwing an error.

 

VarNum =
COUNTROWS (
    FILTER ( Table1, NOT ISERROR ( VALUE ( Table1[RiesgoRegistrar] ) ) )
)

VarTxt = COUNTROWS ( Table1 ) - [VarNum]

 

Changing types in Power BI should not affect SharePoint at all. It should only be reading, not writing to SharePoint.

 

Hi @AlexisOlson 

 

It worked, thanks. However, I have an issue: empty cells (no data). I downloaded the data from SharePoint and I opened it in Excel. This is what I found:

 

250 items:
- 56 cells with text values in the "RegistroRegistrar" column.
- 120 cells with number values in the "RegistroRegistrar" column.
- 74 cells with no data (empt) in the "RegistroRegistrar" column.

 

VarTxt is 56 which is OK. Howerver, VarNum is 194 (I think that number is the result of 120 cells with number values + 74 cells with no data (empty)).

 

How can we excluse cell with no data (empty).

 

Thanks again.

@efebo 

Following @AlexisOlson 's answer, you can try this

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table',NOT(ISERROR(VALUE('Table'[CONTENT])))&&NOT (ISBLANK('Table'[CONTENT]))))

1.PNG2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks @ryan_mayu.

It worked. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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