In this lesson, we will create a report on the percentage of gross margin for each customer, using the data in basic command.
Customer's gross profit marginTutorial
|
Gross profit is the total revenue of the store having deducted cost of goods sold. The gross profit for customers only shopping for bargain products is likely to be low. Nevertheless, the gross profit from loyal customers is high. By deriving the gross profit, it helps us differentiate profitable customers and bad customers.
Most commands to create the report is covered in Basic commands. Below is the process flow to generate the report, think through each step carefully before proceeding.
Answer: Process flow
After we have prepared the work flow, let's rethink each step and start creating the script.
#/bin/bash #=============================================================== # MUSASHI bash script #=============================================================== #---- Title title="Customer's gross profit margin" #---- Comment comment="Basic Reports" #---- Variables inPath="/mnt/h00/tutorial" #--------------------------------------------------------------- # Commands #--------------------------------------------------------------- xtdelnul -f customer -i $inPath/dat.xt | xtcut -f customer,amount,grossprofit | xtagg -k customer -f amount,grossprofit -c sum | xtcal -c 'round((($grossprofit/$amount)*100),0.1)' -a grossprofitmargin | xtcut -f customer,grossprofitmargin | xtheader -l "$title" -c "$comment" -o profit.xt #=============================================================== |
The following are additional exercises for this lesson, try them out and check your results with the scripts and output given below.
Report Name | Script Name | Result (xt) | Result (html) |
The 20 customers with the lowest gross profit margin | profit1.sh | profit1.xt | profit1.html |
Top 5 Customer with lowest gross profit margin by Year Month and Day | profit2.sh | profit2.xt | profit2.html |