Best Of
Re: Lead Function in Rank and Window Returning Self Referencing Value
Just to clarify, but is StudentIndex always populated and is it unique for each partition?
Re: Using date filter as input for Beastmode calculated field
@BenjaminPapes It was worth a shot at least. Another option would be to create a global variable where the user can select a year to replace the max date like this:
sum(case when YEAR(`Sales_Date`) = `Year_Variable` then `Sales` else 0 end)
Re: Business days between date function
Hi @LCash
Here's a simplified version for calculating the number of business days since today without using the WEEK function:
-- Calculate the number of actual days between the two dates DATEDIFF(CURRENT_DATE(), `date_start`) -- Subtract the days of weekends between the two dates - DATEDIFF(CURRENT_DATE() + INTERVAL (1 - DAYOFWEEK(CURRENT_DATE())) DAY, `date_start` + INTERVAL (1 - DAYOFWEEK(`date_start`)) DAY) / 7 * 2 -- If we start on a Sunday remove the partial week start - (CASE WHEN DAYOFWEEK(`date_start`) = 1 THEN 1 ELSE 0 END) -- If we end on a Saturday remove the partial end of the week. - (CASE WHEN DAYOFWEEK(CURRENT_DATE()) = 7 THEN 1 ELSE 0 END)
Re: How to get WoW comparison by changing global date filter?
@Joyce The reason this issue occurs is because changing the filter excludes the rows necessary to complete the calculation since your beast modes are written to only calculate results for data from the past two weeks. In other words, when you filter to more than 2 weeks ago there are no rows being included that satisfy the condition of your case statements.
You can get around this by using a date variable in the place of CURRENT_DATE() in your beast modes and hiding the date range selector in your card.
Re: Percentages on this table
@ggountanis You're getting zeroes because you're dividing the actual word by count. Also, how you're intending your code to work would just give you 1's because, for White, you would be dividing the number of white by the count of items in white. Another item, you don't need to do separate case when's for each ethnicity because your Ethnicity column will do the grouping for you. Try something like this:
SUM(1)/SUM(SUM(1))FIXED()
Since your columns are doing the grouping, the numerator will take the total in each grouping, and then the denominator will take the count of the entire population.
Re: Automatic Record Matching - Customers
Hey kpmwinston - I recently had this same requirement and solved it via MagicETL and using the Dynamic Unpivot + Python Scriprting blocks. The idea goes something like this:
- Add dataset A as a datasouce in MagicETL
- Add dataset B as a 2nd datasource in MagicETL
- Drag two unpivot blocks into your flow, and connect one to Dataset A, one to Dataset B
- This will transform both datasets a 'vertical' stacked dataset (turning your rows into columns)
- So both datasets should now be laid out like this:
In your case, as part of setting up the unpivot block, the product column above would be your column names (Customer Name, Customer Address), and sales column above would be equivalent to their values.
- Connect both unpivot blocks to python scripting blocks and leverage the fuzzywuzzy python library to compare the 'values' from dataset A and dataset B to get a confidence score.
- This same process could be done on the column names if you wanted to do a fuzzy match to determine if the different column names between both datasets are related. If they are you could leverage a bit more python to conform the column names between both datasets automatically.
I won't go into a lot of detail on the step above, but the following link provides some sample MagicETL python scripting using the fuzzy wuzzy python library that outputs the matches and confidence scores that you can then connect to an output dataset. In the example link, this person is trying to match addresses from 2 different sources where the addresses are very similar but may not match 100% (so you cant leverage standard joins between them) which sounds nearly identical to what you're trying to achieve.
I know this isn't a detailed step by step, but it should get you close enough to an actual solution to your problem.
Re: Antithesis Filtering on Dashboard
@Stuck That's an interesting use case. The best way I can think of to accomplish this is to create an "anthithesis" dataflow for that particular card. You can do this in MagicETL following these steps:
- Add a filter tile to exclude all rows for a particular project (e.g. bananas)
- Rename the field that is used for the project filter (e.g. `Project2`)
- Add a new column with the same name as the original project filter and a constant value of the project that was excluded in the ETL filter ('Bananas')
- Repeat steps 1-3 for each project
- Append all branches
Once the dataset is set up, update the antithesis card to replace any mention of the project field to Project2. Then when a user filters the dashboard on the original project field, the card will filter to include rows of all other projects.





