Calendar Table in Tableau - calendar

I am trying to replicate in Tableau the following data model that I have in PowerBi:
Stores Table: It has the name of each store, its characteristics and a key that connects to the Sales Table and the budget table.
Sales: It has the date, sales and key that coonects to Stores Table.
Budget: It has the date, budget per day and key that coonects to Stores Table.
Calendar: It has the date in a period of time.
The logic in this model is the next one, compare Budget v/s Sales for every day and for each kind of Stores. Calendar table filter days or date for both tables.
In Tableau I make the following connection, where only the information from the sales table is filtered by Calendar table
The idea is to connect both tables as in power bi, is this possible?

Related

SQL Trigger - Allocation Amount

i need to create a complex trigger in my database.
I try to explain my problem:
In my database I have 3 tables: Cash table, invoice table and installment payment table. Now I need to create a trigger. When I enter a payment in the collection table, the trigger should divide the amount entered by covering the uncovered amounts of the invoices (invoice table) starting from the oldest invoice due date. Furthermore, if installment payments are envisaged, I would need to divide the amount also on any installments starting from the oldest installment due date.
like this function: https://andrewtuerk.wordpress.com/2013/01/17/splitting-allocations-across-multiple-records-in-a-single-statement/
or this: SQL Server Allocation of amount in bill
How can I activate a trigger when I insert row in table?
Many thanks,
Andrea.

Filter multiple tables on single dateTime filter using powerbi

I'm trying to filter with single common date filter multiple tables using powerbi. I'm using postgres RDS engine with powerbi.
What i need is
Filter 4 tables with single dateTime filter.
PS. Each table has own date column
My schema looks like.
Table1
t_id| Date
Table2
t_id| Date
Table3
t_id| Date
Table4
t_id| Date
You need to add a date dimension table, with relationships to the date fields in your tables. Then you can filter this common calendar table and the filter will be reapplied through these relationships.
You can create your own calendar table, or combine the dates from all 4 tables to get a list of all date values (merge queries), or use DAX function like CALENDAR or CALENDARAUTO to create such table. It is a good idea to mark it as date table.
Then add one to many relationships between this calendar table and date columns of your tables (calendar table on the one side).
Add a slicer with the date field from the calendar table, or report level filter on it, depending on your preferences, to filter on it.

Data warehouse design: how to design fact and dimension table with changed delivery date

I am trying to create a PO info data warehouse but i am facing problems with the vendors delayed deliveries. I would like to track the changes when the vendor late on delivery and change the delivery date. How should i organize the table to track the changes, should i put the delivery date in a dimension table or fact table? any help will be appreciated.
I'd just put everything in a single Purchase Order table.
Purchase Order
-------------_
Expected Delivery Timestamp
Actual Delivery Timestamp
Purchase Order ID
Purchase Order Creation Timestamp
...
The primary key would be (Expected Delivery Timestamp descending, Purchase Order ID).
You would create another unique index on (Actual Delivery Timestamp descending, Purchase Order ID, Expected Delivery Timestamp).
This single table would allow you to write queries like, "How many deliveries were more than a week late in the 2nd quarter of 2016?"

Hourly Time Sheets Database Design

Building an internal web-based project management tool for my company. Need some help with the database design for the timesheet component.
We currently use an MS Excel file where:
Column headings - Days of the week
Rows - Time of the day with 30 minutes per row (Row1: 9:00AM, Row2: 9:30AM and so on)
Each cell in the table has a dropwdown menu that fetches from a set of predefined tasks set by a manager and the employee selects one of the tasks against that day and that particular 30 minute time slot.
I want the front end interface to remain the same for the employees.
Need help with designing a database that supports this. I'm open to any suggestions/changes in the restrictions I laid out if it allows for better efficiency. Thank you!
Is something like this what you're after?
Task (all of the tasks an employee might be assigned)
PK: Id
Name
... other details ...
Employee
PK: Id
Name
... other details ...
EmployeeTask (the list of tasks that have been assigned to an employee)
PK: Id
FK: TaskId
FK: EmployeeId
TimePeriod (the row labels)
PK: Id
Start (9:30, 10:00 etc.)
Timesheet (chops out a region of time and says it's one thing - gives column headings)
PK: Id
Start date
End date (don't need this if timesheets cover the same length of time)
EmployeeTimesheetCell
PK: Id
FK: TimesheetId
FK: EmployeeId
FK: TimePeriodId
FK: TaskId
Date or day of the week
Time spent
You'd probably want some kind of status or Finished Date on Task and/or EmployeeTask, so that old finished tasks don't clutter up the GUI.

Database designing help for billing system

I am developing a Electronic Bill Payment System for a bank which has more than 100 customers subscribing for Electronic Bill Payment.
I have a table in which I am creating profile for customer like the following.
Customer Table
Customer_ID (Primary key)
Customer_Name
Address
Phone
Bill_Master
Customer_ID
Enrollment_Date
UtilityCompany_ID
Bill_Generation_Date (lets say 18th of every month)
Bill_Due_Date (lets say 27th of every month)
Our_CutOff_Date (when the bank will generate the bill for payment)
I have created the customer along with clue that which utility company's bill generates on which date and what will be the due date of EVERY MONTH.
I want to create an interface where the user will see the entries of all the customers whoz date is due for bill generation and after that user will click on the particular entry and generate the bill manually by entering the amount and other details so for this I am clueless how to find out which customer's utility company bill is due for generation..
Any help how should I design it and query of it? or would be a automatic procedure like job or something which will do it.
thanks
Well if its a query you need to generate bills that are due 27th of every month and also find the customer's utility company, then you can try this -
SELECT A.Customer_Name, B.UtilityCompany_ID FROM
Customer A inner join Bill_Master B on A.Customer_ID = B.Customer_ID
WHERE Bill_Due_Date BETWEEN GETDATE() AND DATEADD(MONTH,-1,GETDATE())

Resources