Jump to content

adding a column if not brought in by pivot operation


Sundaram Sridharan

Recommended Posts

I query a database to bring in new data and one of the column values are used as column names in a subsequent pivot operation - I need some of those columns to be always there as my chart options depend on it - but sometimes a key value is not present in a data set and hence that column doesn't get generated. How do I make sure a given number of default column names are generated by the pivot even if the data doesn't contain those values I don't mind a full blank/empty column but I need it there.
Link to comment
Share on other sites

I have an idea but not sure it would work for you.

Have a dummy dataset with one row of data and all the columns you need.

Always add this dataset to your original one. In the data canvas, select Add Rows, import this dataset, and you can specify to include all the columns from the new data in the new dataset. As a bonus you get an extra column called Origin that you can use to filter out the dummy data.

Link to comment
Share on other sites

I tried this appraoch and ran into an issue. Let's say "myColumn" is the one that I expect from new data but may not materialize - I have this column in a template along with other column names that will always come through. After pivot operation, I add this table using the "add rows" transform. If that column is not in the incoming records, then this column gets added. But if that column is present, then since I haven't picked this column in the "matching column" settings, this gets added as a duplicate column - like "myColumn(2)" which is undesirable.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...