Removing a dynamic list of columns in powerquery - powerquery

I'm working on a tool to help my team identify changes in some data files. Long story short, i managed to put something together (I'm quite the beginner with powerquery and M) that works well but it lacks user friendliness.
Issue is that not all team members need the tool to check for differences in all columns (different people, different interests). In order to manage this i used the following to remove all the unneeded columns before doing the compare:
= Table.RemoveColumns(myTable,{"col1","col2","col3"... etc
This works but if you want to change the configuration you need to go into the code and modify the list.
My question is the following: Is there any way to integrate a dynamic list into this code? i.e. have that list of columns in an easy to use table, "tick/untick" the ones you want and have the code remove the rest?

If your intent is to allow the user to select columns without entering the query editor then you may benefit from using a parameter table as described here: http://www.excelguru.ca/blog/2014/11/26/building-a-parameter-table-for-power-query/ . You should be able to expose a 2colxNrow table to the user with some predefined column names/numbers. You can use data validation to constrain user inputs to a binary on/off behavior ( https://support.office.com/en-us/article/Apply-data-validation-to-cells-29fecbcc-d1b9-42c1-9d76-eff3ce5f7249 ).
( P.S. Based on the your description of your goals Inquire add-in may alread offer the functionality you are looking for )

Probably the easiest way is to use "Choose Columns" on the Home tab in the Query Editor and then rename the generated step like:
#"CHOOSE COLUMNS HERE ----->" = Table.SelectColumns(Source,{"Column1", "Column2", "Column3", "Column5", "Column7", "Column8", "Column9", "Column10"})
Then when you want to adjust the selected columns, you can press the small wheel to which the arrow is pointing, and a popup will show up from which you can do your (un)ticking.
Alternatively, if you use multiple queries with the same selection, you can create an additional query that outputs a list, like:
let
Source = Table.FromList(List.Transform({1..10}, each "Column" & Text.From(_)),null,{"Available Columns"}),
Transposed = Table.Transpose(Source),
#"CHOOSE COLUMNS HERE ----->" = Table.SelectColumns(Transposed,{"Column2", "Column3", "Column5", "Column6", "Column8", "Column9", "Column10"}),
TransposedBack = Table.Transpose(#"CHOOSE COLUMNS HERE ----->"),
ConvertedToList = TransposedBack[Column1]
in
ConvertedToList
And then use that list in your queries, like:
= Table.SelectColumns(#"Transposed Table",SelectedColumns)
where SelectedColumns is the name of the query with the selected columns.

Related

SSRS Static fields in groups

Good afternoon!
I have created a report with the wizard to create a matrix that is grouped and has drill down rows. I have added filters to the rows and columns and it works great! I then copied that matrix and modified the filters, so I had two matrixes.
But what I really wanted was those two rows in the same matrix, just in different row groups. So I added another group, using the adjacent below option, and then added all the child groupings. However, when I run the report it shows the values for the first row of the drill down data.
When I look at the groupings I can see the one I did manually has a 'Static' field in each row grouping but the ones that the wizard did (with the red ?), they don't have that "extra" row:
What do I need to change or how do I need to add my groups so that I don't get that "static" row and not show the data? I have the visibility set to 'Hidden' and the toggle set up for the prior grouping set data.
Assuming a few things....
the data comes from a single dataset
You are differentiating between Property and Violent crimes by filtering on a column, I'll call it IncidentGroup for the sake of illustration..
I've understood your question ! :)
Get to the point where you had just a single tablix filtered to show 'Property crime'.
Now remove or edit that filter so it shows all the data you need in the report.
Finally, right click on your Matrix1_IncidentCategory row and add a parent group, choose IncidentGroup (or whatever the column is actually called) and check the box to add a group header.
That should be it, there is no need for a second tablix.
Without knowing how you are filtering currently it's hard to give a complete answer but this should get you close, if not all the way there.
If this doesn't work for whatever reason, please post sample data from your dataset output and your current filters.

Crystal Report Groups Duplicate My Values

I'm trying create two groups from two different tables. I choose create new crystal report (As A blank report) then i create two groups like following images:
Then I'm choosing the table. I'm doing this once again with another table i want.
My Crystal report design look like this:
Now my Result is this:
But I want to take this result:(This result is painted)
Maybe it looks like easy for you, but i need a helping hand for solving this.
I choosed link options(Full inner join)
In Design Form
The grouping functionality within Crystal maintains the data relationship and makes it easier to read by not repeating the group text for each line item - if you group by "A", you will see all items, including the "group 2 duplicates" so long as they are in group A. Adding a second group will further refine the subset of results.
This is the intended and expected behavior for Crystal - SQL-level grouping is different and is used for aggregate functions, among other things.
If you are trying to create a multi-column report, look at this
Can I make a two column Crystal Report? - Under Section Expert, go to Details and click the box "format with Multiple Columns", then click Layout at the top and enter the detail size, in inches, as well as the gap between details. if you want your groups to continue in the additional columns, click the "Format groups with Multiple Column" checkbox.
If this does not satisfy your requirement, you may have to reevaluate the report requirements and the dataset limitations.

Does Spotfire provide any simple way of creating an "Other" category to group entries within a filter?

Right now, I am using a filtering scheme which only looks at the data of the 5 or 6 most common entries in the 'Clinic' field. But, there are a handful of other possibilities which might account for a few rows each. They are too inconsequential to include on their own (I am using pie charts and bar charts), but I would like these rows to be accounted for. For this reason, I would like to create an "Other" category which groups these entries together. What is the best way of doing this? I know I can create a calculated column that groups everything aside from the top 5 or 6 in an other category, but I thought there might be a way to keep working with the original column and achieve the same result.
Unfortunately not. In 6.5.x you will have to write a case statement that will specify everything that is not most common to other.
In 7.0.x you can go to insert binned column. Add the bottom you can use values to create a bin. Add the values you want to the bin and call them "Other". Of course if you look at the column created like this, it is a case statement. But it is a whole lot faster than writing it yourself.
Following phiver I came out with this solution in Spotfire 6.5.2:
Add a calculated column
With something like this:
If(DenseRank(Count([Formation]) OVER ([Formation]),"desc")<10, DenseRank(Count([Formation]) OVER ([Formation]),"desc") & " " & [Formation], "10 Other")
Hope that helps.

kibana 4 discover table in dashboard [duplicate]

I'm testing Kibana 4 for a project.
I have created an index from my database table which is composed by 3 fields:
Date
User
Action
I would like to display my index as a simple table (3 column, N rows) in my dashboard.
I tried to use "Data table" visualization but I can't find a way to display my results without any Metrics (Count, Sum etc...)
Maybe is pretty simple and I missed something... is there a way to do this?
Regards,
On the Discover tab, create a view that has just the fields you want and then save that as a search.
On the Dashboard tab, click on Edit then hit the + Create new button to add a widget, but if you look at the top, there's a Searches tab. Select that and add your saved search in.
[Elastic 7.x / 2019 Update]
I was a bit confused when I read #Alcanzar's answer so I am sharing a little more noob-friendly step-by-step how-to here :
STEP 1 : Create the Index Pattern
STEP 2 : Go to the Dashboard view, and create a view on your index
Select each column you want to include/add in your view by clicking "add" on it (The confusing part is that until you do that, you will have a "scrambled" view listing everything in a jumbled way.)
STEP 3 : Go to the Dashboard view, and create a view on your index
The trick is to select the specific columns you want to include... and voila !
Don't forget to save your view, this will help a lot in the process.
In Kibana 7.5.0 you can do it as follows:
Go to Discover section
Select fields you are interested in
Click on Save to save your discover search so you can use it in visualizations and dashboards
Click on Dashboard and create a new dashboard
Click on Add and select the panel
There is no step 6
The accepted solution has its pros (if, for simplicity, you see your index as a table, this is the only way to deal with rows naturally) but also cons (it allows the user to see too much information, by expanding the records that appear in the table; users cannot get an export of the values).
So if you plan to build tables to use in reports seen by users which should not see everthing and may want to get exports of the data, I recommend a different (hacky) approach using Table visualizations:
Say you have three columns A, B and C:
If there are no duplicates considering the combined values of A and B, you can use these two vales as aggregation fields, and then set a Max or Top hit Metric for C.
If even A, B and C have duplicates, then you can use the three of them as aggregation fields and add a Metric count, that will give you the number of repeated rows. This solution makes somehow sense, because instead of repeating the same row 'n' times you just tells you should have repeated 'n' times that row.
If A and B have duplicates but A, B and C are unique, then there is, afaik, no elegant solution. You have to use the three of them as aggregation fields, but then you would have a dummy metric at the end (e.g. count, always equal to 1).
Why? why do we have to go through all of this? that is another question...

Kibana - How to display log as table

I'm testing Kibana 4 for a project.
I have created an index from my database table which is composed by 3 fields:
Date
User
Action
I would like to display my index as a simple table (3 column, N rows) in my dashboard.
I tried to use "Data table" visualization but I can't find a way to display my results without any Metrics (Count, Sum etc...)
Maybe is pretty simple and I missed something... is there a way to do this?
Regards,
On the Discover tab, create a view that has just the fields you want and then save that as a search.
On the Dashboard tab, click on Edit then hit the + Create new button to add a widget, but if you look at the top, there's a Searches tab. Select that and add your saved search in.
[Elastic 7.x / 2019 Update]
I was a bit confused when I read #Alcanzar's answer so I am sharing a little more noob-friendly step-by-step how-to here :
STEP 1 : Create the Index Pattern
STEP 2 : Go to the Dashboard view, and create a view on your index
Select each column you want to include/add in your view by clicking "add" on it (The confusing part is that until you do that, you will have a "scrambled" view listing everything in a jumbled way.)
STEP 3 : Go to the Dashboard view, and create a view on your index
The trick is to select the specific columns you want to include... and voila !
Don't forget to save your view, this will help a lot in the process.
In Kibana 7.5.0 you can do it as follows:
Go to Discover section
Select fields you are interested in
Click on Save to save your discover search so you can use it in visualizations and dashboards
Click on Dashboard and create a new dashboard
Click on Add and select the panel
There is no step 6
The accepted solution has its pros (if, for simplicity, you see your index as a table, this is the only way to deal with rows naturally) but also cons (it allows the user to see too much information, by expanding the records that appear in the table; users cannot get an export of the values).
So if you plan to build tables to use in reports seen by users which should not see everthing and may want to get exports of the data, I recommend a different (hacky) approach using Table visualizations:
Say you have three columns A, B and C:
If there are no duplicates considering the combined values of A and B, you can use these two vales as aggregation fields, and then set a Max or Top hit Metric for C.
If even A, B and C have duplicates, then you can use the three of them as aggregation fields and add a Metric count, that will give you the number of repeated rows. This solution makes somehow sense, because instead of repeating the same row 'n' times you just tells you should have repeated 'n' times that row.
If A and B have duplicates but A, B and C are unique, then there is, afaik, no elegant solution. You have to use the three of them as aggregation fields, but then you would have a dummy metric at the end (e.g. count, always equal to 1).
Why? why do we have to go through all of this? that is another question...

Resources