can i ask for help?
- User
can i ask for help?
- Assistant
Of course! I'm here to help. What do you need assistance with?
- User
I am going to take the output of monthly_metrics and show them in Quicksight. Metric4 and metric5 are rates that would display in quicksight as 85% but they may really be based on 85/100. Users will be able to download the pviot table for the monthly metrics and put them in a paper report. Do you suggest I multiply calculations for metric4 and metric5 by 100 in SQL and then show that in Quicksight or should I keep them as a decimal only with rounding and then display as a percentage in quicksight? If I use this 2nd approach, will metric4 and metric5 stay as percentages if someone downloads the pivot table?
- Assistant
Both approaches you mentioned have their advantages, and the best option depends on your specific use case and requirements. Let’s break down each approach:
Approach 1: Multiply by 100 in SQL
- Pros:
- Pros:
- User
I am sharing the code with you. I am just selecting metrics. Can you suggest how to round metric4 and metric5 to a decimal format or do it to the code? I am going to take the output of monthly_metrics and show them in Quicksight. Metric4 and metric5 are rates that would display in quicksight as 85% but they may really be based on 85/100. Users will be able to download the pviot table for the monthly metrics and put them in a paper report. Do you suggest I multiply calculations for metric4 and metric5 by 100 in SQL and then show that in Quicksight or should I keep them as a decimal only with rounding and then display as a percentage in quicksight? If I use this 2nd approach, will metric4 and metric5 stay as percentages if someone downloads the pivot table?
- Assistant
Certainly! To provide you with an effective solution, I'll assume you have SQL queries that are producing the monthly metrics, which include and . If you want to round these metrics to a specific number of decimal places, you can use the function in SQL. Below is an example of how you might structure your SQL code:
- User
Can you adjust the code for metric4 and metric5 so the percentage is rounded? code follows:
WITH date_reference AS ( SELECT '2024-01-01'::DATE AS start_date, DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')::DATE AS first_day_of_last_complete_month, DATE_TRUNC('quarter', CURRENT_DATE - INTERVAL '3 months')::DATE AS first_day_of_last_complete_quarter, LAST_DAY(DATE_ADD(month, -1, DATE_TRUNC('month', CURRENT_DATE))) as last_day_of_last_complete_month,
LAST_DAY(DATE_ADD(month, -1, DATE_TRUNC('quarter', CURRENT_DATE))) as last_day_of_last_complete_quarter,
- Assistant