Project Hub

Project · Daily cash dashboard

Showing where the cash comes from: 76% by credit card

The problem

The owner learns how much cash came in only at month end, from a spreadsheet nobody trusts, so late payments and weak days are found too late.

The solution

A Power BI cash page on a six-layer warehouse with a star schema: money in by day, payment method and region, what is still due on instalments, and what is late, with every total matching the source.

How it works

  • Load: Orders and payments by method, instalment and day, loaded as they are into the Bronze layer
  • Clean: The Silver layer types and keys the same rows
  • Rules: The Gold layer defines cash in, cash still due and late payments once
  • Model (star schema): The Semantic layer: a star schema with a date table, so every day, month and year adds up
  • Report: A daily cash page: what came in, what is due and what is late

A closer look

Pipeline diagram, left to right through six layers: load.py loads the orders, payments, customers, payment method and region files as text into the Bronze layer, refused rows to bronze.quarantine; one SQL file per layer then builds five typed Silver tables, the Gold table instalment with the cash rules, the Semantic layer's fact_instalment and three dimensions, and three Analytical views; the notebook and Power BI in the Reporting layer read the Semantic and Analytical layers only.
How the input files become the cash page, layer by layer.
Where the money goes: 103,886 payments worth BRL 16.0 million split by payment method (credit card BRL 12.5 million, boleto 2.87 million, voucher 379 thousand, debit card 218 thousand) and flow into received (BRL 14.4 million, 90.0%), still due on card instalments (BRL 1.56 million, 9.7%) and never paid (BRL 37 thousand, 0.2%) on the report date, 3 Sep 2018. 2,301 payments were confirmed late, 78% of them boleto.
Instalments push card money into the months ahead.
Data flow: one box per step, in run order, from the input files to the report.
The steps, in run order.
The Semantic layer's star schema: fact_instalment (296,425 rows, one per instalment, key payment_id plus instalment_no) joins dim_payment_method (5 rows), dim_state (27) and dim_date (1,827 dates, every day of 2016 to 2020) on the cash date; order_date is also a foreign key to dim_date, with no relationship in Power BI.
The Semantic layer: one fact table, three dimensions.
Chart: the BRL 14,415,391.61 received, by payment method (credit card 76.1%, boleto bank slip 19.9%, voucher 2.5%, debit card 1.5%) and by region (Southeast 64.8%, South 14.5%, Northeast 11.7%, Central-West 6.4%, North 2.6%).
Where the cash comes from.
Chart: cash received each month up to the report date of 3 September 2018, peaking above BRL 1.1 million a month, then the card instalments still due after it, BRL 1.56 million in all.
Cash received, then instalments still to come.
Chart: the share of payments confirmed more than three days after the order is 9.1% for boleto bank slips, 1.9% for debit cards, 0.8% for vouchers and 0.6% for credit cards.
Boleto payments are confirmed late most often.

The code

select
    i.payment_id,
    i.order_id,
    i.instalment_no,
    i.instalments,
    i.payment_type,
    i.customer_state,
    i.order_date,
    i.cash_date,
    i.amount,
    case when i.cash_date is null       then 'Never paid'
         when i.cash_date <= r.report_date then 'Received'
         else 'Due'
    end as status,
sql/3_gold.sql

The impact

  • Cash in by day on one page, so a weak day shows before month end.
  • Instalments still due and late payments listed.
  • The payment methods and regions that bring the money in.

The result

103,886 payments: 76% of the cash in arrived by credit card, and 9.7% of the money was still due on card instalments.

Built with

  • Power BI
  • DAX
  • Power Query
  • PostgreSQL
  • SQL