Using measure as an attribute
While working on a report I came across this issue:
I have a list of accounts/ For each account, I have the number of days in which it was recommended.
“Count recommendation date” is a measure that counts distinct days.
For example, account number 18420438 was recommended in 17 different days in September:
Now I’d like to create an aggregated chart showing account distribution by “count recommendation date”.
For example, 1 accounts was recommended 17 days;
1 accounts was recommended 16 days;
9 accounts were recommended 16 days, etc
Something that looks like this:
Is there a way to turn the measure into an attribute?
Please note that it has to be dynamic. For example, if I wanted to view October’s data the attribute elements should change accordingly.
Thank you,
4 replies
-
Hi
By creating new table we can achive the resulsselect the new model for Discover, locate the "Add New Database" icon on the right.
Click on the icon and select the Custom Query option.
-
Use the following script to create a distinct day count based on the customer:
Sample Copy code
SELECT [Customer Name], COUNT(DISTINCT[Purchase History]) AS count_recommendation_date FROM [data_synthetic] GROUP BY [Customer Name];
After updating the script, check the selection box to show the measure as a dimension.
Click the Finish button to apply the changes.
In the Dimension Panel, select the
count_recommendation_date
and then create a customer count viacustomerName
.This will display the desired scenario where you can see the customer count grouped by the number of distinct recommendation days.
Chart
Hope that helps!.
Thanks & Regards
Raja Sambasivam
-
Hi
Using Custom Visual Script in Pyramid AnalyticsTo achieve your desired scenario without creating a new table, you can follow these steps using the Custom Visual Script option in Pyramid Analytics:
Add Columns to Dropzones:
- Drag the Account column into the Row Dropzone.
- Drag the Recommendated date DST Count into the Values Dropzone
Use Custom Visual Script:
- In the Custom Visual section of Pyramid Analytics, you can utilize the D3.js chart library for visualization. D3.js provides a wide range of charts and visual styles to choose from, allowing you to pick one that suits your needs.
- Here’s a sample script you can adapt for your visualization using D3.js:
Place the Code:
Save and Apply:
- After creating the custom visual, save it.
- Apply it to your Discover report.
- Ensure you repeat the dropzone selections as outlined in Step 1 to maintain the same scenario in your visual.
- With date range selection
The flexibility of custom visual scripting allows you to use various chart types and libraries like D3.js to tailor the visualization to your preferences.
Thanks,Raja Sambasivam