I have a table with monthly summary of KPIs. The customer now wants to be able to make adjustments to the original data. I have to allow for adjustments as well as preserving the original data. The report I generate will show original data + or minus any adjustments.
Here is an example of what I need to be able to do.
Table A
Report_Month 7/31
KPI_1_QTY 88
Customer requests to decrement KPI_1_QTY by 5. This results in KPI_1_QTY being 83. I need to report 83 but have to keep the original value as well.
Any ideas on how to code this?
There are a number of ways of addressing the general problem of keeping audit trails of original data. The simplest is to timestamp the row and include an "IsHead" bit field.
For example:
FactID Timestamp Attribute Value IsHead
2 8/1 KPI_1_QTY 83 true
1 7/31 KPI_1_QTY 88 false
If you want the "head" branch of the data, you filter on IsHead = true (usually you create a view for this).
If you want the change log, you display all the rows in descending order by timestamp.
If you want the data as it exists at a specific point in time you reconstruct the data as it existed on that date (left as an exercise to the reader).
If there are properties associated with the adjustment, create another table with the fields you need to describe the change. For example...
FactID ModifiedBy ModifiedOn ValueDelta Description
2 Fred 8/1 -5 Adjusted KPI_1_QTY per customer request
Related
I am using a US shootings database where the event is specified by 3 columns, state event occured, date, total casualties. I want to make a dashboard in Tableau that has dynamic sum and sorting where if the year column was a page that I could click through, the graphic would reflect the top ten states of sum(casualties) of that specified range. So my data ranges from 1924-2022, and if I started the page at 1980, it would graph the top 10 states with the sum of totals between 1924-1980. The next page could potentially be a different top 10 of states and would reflect the current top 10 states as the sum(casualties) from 1924-1981.
I hope this makes sense. I apologize if it does not as I am just starting out. I did attempt to sort the data in python by making a column for each year, and you could move horizontally along a state to see it's totals change as each year goes by. Would it be best to add these year columns as a group and sort by top 10 and year that way?
Edit:
Attempting to click through the year filter and dynamically sort the graph by top 10 states with total shootings from 1924-current year
Can you use SQL to query the database? If so, you can insert a date parameter in the query that replaces the use of pages to calculate the sum based on the earliest datapoint to the year you have selected and then just click show parameter. When you create the parameter make sure you set step size to one year and switch the parameter to slider. You can also create a state parameter that is based off that column of data and then use it to filter the data in SQL. However, you may need to use a calculated field or SQL case statements if you want to change the granularity from all the states to one selected state.
I hope this helps you. If you need more clarification, please comment and I will try to provide an example.
I have changed this question and the correct working answer to reflect explicitly the solution for my exact problem.
This is for accounting purposes. I'm trying to create a debit and a credit table so that I can keep track of payments and have balanced books for my business partner.
I thought to try =if(1, value) in the credit and debit tables however I will get a whole lot of cells of FALSE return values when it discovers values of 2 and vice versa which is not practical.
I have rows of information which I designate a type either 1 or 2. For example:
type
description
amount
date
comment
2
cable
50
12 May
1.0mm flat
1
payment 001
30
24 May
2
plugs
10
8mm size
2
bits and pieces
15
1
payment 002
20
30 May
I have a debit and credit columns in another sheet so what I want to happen is I want each line of the first table and any new line added thereafter sorted into a credit column and a debit column automatically.
Description
Date
Comment
Credit type
amount
payment 001
24 May
1
30
payment 002
30 May
1
20
Description
Date
Comment
Debit type
amount
cable
24 May
50
2
1.0mm flat
plugs
10
2
8mm size
I understand that there must be formula in the credit and debit type cells.
I need some kind of sorting system.
Many ways to do that.
If you need just one table use
=SORT(A2:C8,1,1)
OR EVEN
=QUERY(A1:C8,"where A is not null order by A",1)
If you need two tables just use it twice
One can also use
=QUERY(A1:C8,"where A=1 order by A",1)
AND
=QUERY(A1:C8,"where A=2 order by A",1)
(Do adjust the formulae according to your ranges and locale)
Credit to #marikamitsos and theartsnettutors with the earth for giving me confidence to resolve this problem and giving me the tools to figure it out for myself.
The best tool to use is QUERY using the SELECT function and then selecting the columns from the RAW data table in the order that you want the data printed:
RAW data:
Solution for CREDIT table:
Solution for DEBIT table:
I am creating a Google Data Studio report for a car dealership and I have a problem.
I have made these 3 screenshots to illustrate:
If you see on the first screenshot, the datasource is pretty simple, used/new indicates weather the car being sold is new or used and if it is a sportscar or family car, and exchange/clean deal indicates weather the dealership takes/buys the customers old car in for a trade off in price. The rest should be self explanatory.
On screenshot2-3 you see my report, I have one table for each salesperson and it shows the amount of sales for each combination that has sales.
The problem is this, I want the tables to show each combination even if it does not have any sales at all, it should just show 0 then in record count. Like Mike on the left has more combinations than john, I still want Johns table to show those combinations just with a 0 then, and it should be sorted the same on each table so they look the same, just different data in the cells.
Is this possible to do?
To solve this problem, you need to make a combination of data, from the database with itself. Your main analysis dimension, which will generate your combinations, is used/new and Exchange/Clean deal. So your combination should be:
The filter defined in the second database (right base) must contain a filter telling which person the table will be destined for. So, for each table, you must make a new combination that contains the person-specific filter.
I just took a sample from your original database (10 first lines) and the result is:
Imagine a list on the left filled with employees going down the spreadsheet and headers across the top based categorized on infractions that an employee might violate. this sheet is connected to another sheet which adds a one every time a form is submitted against the employee adding up for the quarter. So employee john smith has across his row would show a 0 if he never committed this infraction and add a 1 to the column each time he did so a row might look like this. John Smith 0 4 5 0 1
The goal is to show the experts name and infraction with how many times this infraction took place removing the infractions that he did not commit so ideally it would look like John Smith 4 5 1 and the header of each number would show what he did.
The goal is to make it much easier to see who did what essentially. There will be over 100 employees and alot of 0's so optically it would look better to distill in order to quickly identify who did what and how many times.
Any ideas?
V lookups and important ranges based on if this is greater than 0 is tedious and does not exactly pull what we want. Essentially omitting the 0s and just showing what an employee has done rather than what they have not done is the goal. All index and match formulas do not seem to specifically answer this problem
simple Index V lookups and matching formulas have been tried
Not able to reflect all three variables (employee/frequency/infraction) while not showing on a master list the people who did not commit the offense
There's a few ways you could set this up. I would set this up so it
Column A = Employee
Column B = Infraction
Column C = 1
Column D = Date
That way you can do a pivot summary and have the employees, with their infractions below their name and the months/years they occurred. Also you can adjust this table as necessary, such as filter by the employee name or by date or by infraction.
The added benefit is you could create a chart with all of these as filters, like cutoff a date range or pick an employee or infraction and it can show a bar graph of all the infractions by month or something like that.
I would agree that listing your data of infractions line by line (as they happen) and using a pivot table would probably be the easiest.
You could also use the AGGREGATE function to pull from a large database as well. This way you could type in an employees name, and a list of all infractions would pop up next to the name (or wherever you would want it) with as much detail as you would like. This way is more complex, but using both a pivot table and the AGGREGATE function might get you the best of both worlds (you could searching infraction types, dates, employees, employee types, and get all the details in the world if wanted).
Hope this helps!
JW
I have two tables in PowerBI and a slicer, presented below in an abstracted way.
I want to know the number of orders placed for a customer in a given date range. This data is a sample for illustration - there are actually around 10,000 Customers and 500,000 Orders and both tables have many other fields, Ids etc.
My challenge -
Whilst this is easy enough do by relating the tables and doing a count, the difficulty comes in when I still want to see customers with 0 orders and on top of that I want this to work within a date range. In other words, instead of the customers with no orders disappearing form the list, I want them to appear in the list, but with a 0 value, depending on the date range. It would also be good if this could act as a measure, so I can see the number of total customers that have not ordered on a month by month basis. I have tried outer joins, merge queries, cross joins and lookups and cant seem to crack it.
Example 1: If I set the order date slicer to be: 02/01/2017 to 01/01/2018 I want the following results
Example 2: If I set the order date slicer to be: 03/01/2017 to 06/01/2017 I want the following results
Any help appreciated!
Thanks
This is entirely possible with a Measure. When you're using the Order field to count the rows for each customer, you're essential doing a COUNTROWS() function.
With your relationship still active, we can Prefix this in a measure to check for the blanks, and in those cases, return 0. something like this would work
Measure = IF(ISBLANK(COUNTROWS(Orders)),0,COUNTROWS(Orders))
In this case, 'Orders' is the table containing the Order and Order Date fields