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

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

Related

Need to convert array with similar columns into single list with only 2 columns and remove blanks

I have an array of product use cases and columns for each feature--which creates an array of varying columns depending on the row
I want to convert to a single list of all features with a second column for the relevant product use case
I have an example attached---any tips for converting to a list?
Screenshot showing current state and ideal state with dummy data---actual data set is 50+ rows and 50+ columns
This could be done by formula in Office 365:
=LET(data,B3:I7,
r,ROWS(data),
c,COLUMNS(data)-2,
first,INDEX(data,INT(SEQUENCE(r*c,,1,1/c)),1),
second,SUBSTITUTE(INDEX(data,INT(SEQUENCE(r*c,,1,1/c)),2+MOD(SEQUENCE(r*c,,0),c)+1),"",""),
all,CHOOSE({1,2},first,IFERROR(--second,"")),
FILTER(all,INDEX(all,,2)<>""))
But using Power Query would be easier.

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!

Google Data Studio : how to obtain a SUM related to a COUNT_DISTINCT?

I have a dataset including 3 columns :
ID transac (The unique ID of the transaction - Dimension)
Source (The source of the transaction - Dimension)
Amount € (The amount of the transaction - Stat)
screenshot of my dataset
To Count the number of transactions (for one or more sources), i use COUNT_DISTINCT function
I want to make the sum of the transactions amounts (for one or more sources). But i don't want to additionate the amounts of the transactions with the same ID !
Is there a way to do this calcul with a DataStudio function ?
Thanks for your answers. :-)
EDIT : I saw that we could do this type of calculation via SQL here and I would like to do this in DataStudio (so that I don't have to pre-calculate the amounts per source.)
IMO, your dataset contains wrong data. Each value should be relative only to that line, but this is not the case: if the total is =20, each line should describe the participation of that line to the total. With 4 sources, each line should be =5 or something else that sums 20.
To solve it in DataStudio, you need something like CALCULATE function in PowerBI, but currently DataStudio doesn't support this feature.
But there are some options to consider to repair your data:
If you're sure there are always 4 sources, just create a new calculated field with the expression Amount/4 and SUM it. It is not an elegant solution, but it works.
If your data source is Google Sheets, you can easily repair the data using formulas, like in this example:
Link to spreadsheet
For this spreadsheet, I used this formula in adjusted_amount column: =C2/COUNTIF(A:A,A2). With this column in DataStudio, just use the usual SUM aggregation function to summarize it correctly.

MS Access - Color cells in a query that has the same numbers in a specific column

In my database i have columns with information that are match togheter with a column named MsgNumber this column looks like this:
Where if it´s 1 1 the two rows have some coherent information. 2 and 3 3 3 and 4 4 4 4 and so forh all the rows are aligned that way. My goal is to get the query to order the cells by color as show in the next pictur:
I tried with condition formation but then i needed to do a seperate "report" i need to edit the rows directly in the query. (doing it manually is not an option). Can it be done? Thanks

Generating Working Hours using SQL Server Query

I have this data and I need to generate a query that will give the output below
You can do this kind of groupings of rows with 2 separate row_number()s. Have 1 for all the data, ordered by date and second one ordered by code and date. To get the groups separated from the data, use the difference between these 2 row_number()s. When it changes, then it's a new block of data. You can then use that number in group by and take the minimum / maximum dates for each of them.
For the final layout you can use pivot or sum + case, most likely you want to have a new row_number for getting the rows aligned properly. Depending if you can have data missing / not matching you'll need probably additional checks.

Resources