Help! How to design summary number for this case?
Here is my map card. in summary number area, I show the top 5 provinces parcel %.
Synchronizing with the map, below is the filters.
when there is none of the filters selected, the summary number on the map is correct.
when there is any of the filters selected, the summary number on the map is incorrect.
below is my design for summary number on beast mode.
Top5省份包裹数 means top5 provinces parcel quantity
快递单号 means parcel / express ID
By SQL data transformation, I added some fields as column for each line of raw data. the fields are 'By Province包裹数‘ , ‘Rank’, 'Top5省份包裹数'.
By Province包裹数 means the total parcel quantity for each province
Top5省份包裹数 means the total parcel quantity for top 5 provinces. when the province of the line of data ranks in total parcel quantity within 5, there is total parcel quantity filled up with the line of data, if not, 0 is filled up with.
So, here is my current design.
my question is, when there is filters selected for the map chart, how can I design to show the right summary number? for examples, to select by store or by time period is the very common business scenarios.
could you please help and give some ideas? thank you very much!
Best Answer
-
Got it. Unfortunately, there is not a native function in Domo that can produce the top N analysis that you are trying to accomplish. However, I believe you are able to achieve this by coding a Python script in the ETL that can dynamically adjust the summary number at the card level after filters have been applied. Please see the Python script below for an example:
# Import the domomagic package into the script from domomagic import * # Read data from inputs into a data frame input1 = read_dataframe('NAME OF ETL TILE PRECEDING THIS PYTHON TILE') # Function to calculate top N provinces based on parcel quantity def calculate_top_n_provinces(df, N=5): # Group by province and calculate the total parcel quantity for each province
province_totals = df.groupby('Province包裹数')['快递单号'].count().reset_index()
province_totals.columns = ['Province包裹数', 'TotalParcels']
# Sort by total parcel quantity in descending order and get the top N provinces
top_n_provinces = province_totals.sort_values(by='TotalParcels', ascending=False).head(N)
return top_n_provinces # Function to calculate summary numbers for top N provinces def calculate_summary_numbers(df, top_n_provinces): # Filter the input data frame to include only rows from the top N provinces
filtered_df = df[df['Province包裹数'].isin(top_n_provinces['Province包裹数'])]
# Calculate the summary number, which is the total parcel quantity for top N provinces
summary_number = filtered_df['快递单号'].count()
return summary_number # Get the top 5 provinces based on parcel quantity top_5_provinces = calculate_top_n_provinces(input1, N=5) # Calculate the summary number for the top 5 provinces summary_number = calculate_summary_numbers(input1, top_5_provinces) # Add the summary number to the data frame for visualization purposes input1['Top5省份包裹数'] = summary_number # Write the data frame so it's available to the next action write_dataframe(input1)This logic should produce the dynamic calculation logic you are looking for in the summary number of this heat map card, even after when filters are applied.
0
Answers
-
Are you trying to create a dynamic Beast Mode calculation that adjusts based on the filters applied to your dashboard, ensuring the summary number reflects the top 5 provinces' parcel quantities under those conditions? Or are you looking for a static calculation that consistently shows the top 5 provinces' parcel quantities, regardless of any filters applied? There could be a few different solutions depending on whether you need the summary number to update dynamically with filtering or remain constant.
0 -
@Jonathan53891 the dynamic one. Can you pls help? thank you!
0 -
Got it. Unfortunately, there is not a native function in Domo that can produce the top N analysis that you are trying to accomplish. However, I believe you are able to achieve this by coding a Python script in the ETL that can dynamically adjust the summary number at the card level after filters have been applied. Please see the Python script below for an example:
# Import the domomagic package into the script from domomagic import * # Read data from inputs into a data frame input1 = read_dataframe('NAME OF ETL TILE PRECEDING THIS PYTHON TILE') # Function to calculate top N provinces based on parcel quantity def calculate_top_n_provinces(df, N=5): # Group by province and calculate the total parcel quantity for each province
province_totals = df.groupby('Province包裹数')['快递单号'].count().reset_index()
province_totals.columns = ['Province包裹数', 'TotalParcels']
# Sort by total parcel quantity in descending order and get the top N provinces
top_n_provinces = province_totals.sort_values(by='TotalParcels', ascending=False).head(N)
return top_n_provinces # Function to calculate summary numbers for top N provinces def calculate_summary_numbers(df, top_n_provinces): # Filter the input data frame to include only rows from the top N provinces
filtered_df = df[df['Province包裹数'].isin(top_n_provinces['Province包裹数'])]
# Calculate the summary number, which is the total parcel quantity for top N provinces
summary_number = filtered_df['快递单号'].count()
return summary_number # Get the top 5 provinces based on parcel quantity top_5_provinces = calculate_top_n_provinces(input1, N=5) # Calculate the summary number for the top 5 provinces summary_number = calculate_summary_numbers(input1, top_5_provinces) # Add the summary number to the data frame for visualization purposes input1['Top5省份包裹数'] = summary_number # Write the data frame so it's available to the next action write_dataframe(input1)This logic should produce the dynamic calculation logic you are looking for in the summary number of this heat map card, even after when filters are applied.
0 -
so great!!! I need time to digesting all of these above. thank you very much. you are such a great man!
0 -
My pleasure! Always more than happy to help!
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 621 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 743 Beast Mode
- 58 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 395 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive