Counting rows per special character in SQL Server - sql-server

I have identify records that contain non-Alpha characters. I know how to do that part. I am using first and last name fields. The odd part of this is that I have to provide a count of rows per character. So for example, 500 rows contain $, 400 rows contain &, and so on. Dashes are Ok, and periods are ok if they are contained in a suffix. Is there any good way to pull and display this in a table format? Maybe a column that contains the characters and then a second column that has the counts of records that contain that character. I am on SQL Server. Thanks!
Here is an example of the output I am looking for.

Related

Tableau, Multi-Step - Split a string column then group the new columns into a single dimension to count results

The question is difficult to describe. If it is relevant, my Tableau is connected to Salesforce. Here are the steps I've taken and result I am looking for -
I have a text field where up to 37-categories can be listed in any order:
Example of Original Dataset
Each row can have 1 - 5 records, delimited by ";" which I can split. The result of the (custom) split gives me a different column for each separated string:
Result of Custom Split
What I am looking for is a single column used as single dimension showing results over a Time dimension. The result would look similar to this, but row-1 would be the row-1 value count ("Call Back") across all of the columns.
Result I Want
Any direction would be excellent. Thank you!

How to remove a specific string from a character on multiple rows of data?

I have a table with a column for ID, it is a varchar, this column however has to be 14 characters long. The vendor that supplies this table left some with 15 characters. The format of the number is 'FL000000123456.' So, we asked them and they told us to just remove off the leading zero. I need to run an update on this table to remove that first zero, but I do not how to do that. I ran the LEN function to bring me back the ones that have a LEN of > 14. I can replace or run an update on the individual basis, but the table has over 1 million records and about 45,000 of them have the > 14 error. I do not work on SQL most of my time, so I am not as adept as some of you will be, but any help I can get would be greatly appreciated.
output: FL0000000123456 -- 15 chars
desired output: FL000000123456 -- 14 chars
Assuming that therefore you want to remove the 3rd character, you could use STUFF:
SELECT STUFF(YourColumn,3,1,'') AS NewColumn
FROM dbo.YourTable
WHERE LEN(YourColumn) = 15;
Of course, this does mean if you have a value like 'FL1234567891234' you would end up with 'FL234567891234', but I am assuming that won't happen.

PowerBI (DAX) - Countif Contains Column Value (thousands of rows)

Relatively new to PBI and need a hand with counting totals of delimited values in a single column. So my source column looks something like:
ID Code
1 abc1|bcd2
2 def2|abc1|ghi3
3 bcd2
I've created a new table based on the same query that takes just this column and splits it into individual rows by the pipe delimiter:
Individual Codes
abc1
bcd2
def2
ghi3
Now I'd like to plot the number of occurences of each individual code in the original code column. I had intended on doing this using a calculated column, but I don't know if that's even the best approach. So having something like:
Individual
Codes Counts
abc1 2
bcd2 2
def2 1
ghi3 1
If it's possible to relate the tables, I'm not sure how. I've tried filter approaches similar to this but that's caused crashes. The current source data has maybe 50k rows (with 8k individual codes), but potentially these values could be 10-100x larger so I imagine it's best to avoid something that's creating filters of the source data for each row of the Individual Code table.
Much appreciated!
Original Data
Then you can split Your code column into new rows using delimiter
and then you can group your rows based on Code and count rows as below
and when you come back to Visualizations you can have your desired output

Apply different formatting to different columns in a column group

I have some summary data, by year, that I am displaying in a tablix, in a pivot table fashion. The first column is the year, each row is a single year, and each column contains counts and dollar amounts from a query.
By default all of the value columns are formatted the same way. However, I need the first 4 columns formatted as a whole number (total counts) and the last 2 columns formatted as currency or 2 decimal places with commas. As shown here, my counts have .00 that I don't want shown.
Here is something that will get you going in the right direction:
=IIf(Fields!Type.Value = "Claims Filed" OR Fields!Type.Value = "Claims Approved", FormatNumber(Fields!Value.Value, 0), FormatCurrency(Fields!Value.Value, 2))
You will have to fill in for the other options, or switch these around to use the money values in the first part of the IIf since it is the shorter list. But, this should give you a good idea of how this can be done.
It is just a simple matter of conditional formatting, SSRS style.

Import a text file by converting repeating groups of lines into columns

My data file looks like
1234567 7654321
TEXT ABOUT STUFF
ON MULTIPLE LINES
NOT SURE HOW MANY
1234567 7654321
TEXT ABOUT STUFF
ON MULTIPLE LINES
NOT SURE HOW MANY
The only thing for certain is a new record starts with 2 sets of numbers that are 7 characters long. The numbers are also on a new line and appear as my sample data above.
I am using SQL Server Express on Windows 8.
Ultimately I need the first group of numbers in a column, 2nd group in another column and the remainder of the text in the 3rd column.
This is the realm of ETL. The SQL Server was of doing this is to use SSIS.

Resources