Magento 2 Min - max product attributes query - magento2

How do I filter using two separate product attributes?
Say I have two attributes assigned to products min-height and max-height and I want to use the URL query to return all the products contained in the limits but not the products where they intersect with these.
E.g.
Inputs entered:
Min Height: 60 cm
Max Height: 80 cm
www.example.com/all-cats.html?min_height=60&max_height=80

Related

Tableau How to evenly split a Ranking Table into two

I am trying to evenly split a ranking table into two.
I tried to create a calculated field using rank to divide the data into two groups.
The problem with this approach is that there are too many entries in the first column because they are tie with rank 1.
I don't want to break the tie but display evenly in both columns.
So, desired output will look like...
25 states with Rank 1 are displayed in column 1, and the rest 12 rank 1 states and the other states from rank 38 to 49 are displayed in column 2.
In order to split your rows within a specif number (say 25) you can't rely just on rank due to same values for multiple rows.
Even though your Rank calculated field must be shown in the chart, you can add another calculated field based on rank_unique which will provide you a progressive number for rows having the same value for the specified metric.
Just use the specified function:
RANK_UNIQUE(SUM([Value]),'desc')
And then use the calculated field as a filter to "split" the results as you need (in this example 1-4, 5-8).

Return a Record Based on Weight Field in MongoDB

I have a 2 collections. One is for Locations and another for configurations. Each location can have many locations. When I query a location I want to return a configuration based on the weight assigned to that configuration. As an example:
location A has 3 configurations
Config1.weight = 500
Config2.weight = 1000
Config3.weight = 1000
The weights above mean that Config1 has a 20% chance of being returned and Config2/3 have a 40% chance each. I get this percentage by adding the weights and then dividing by the individual weight which gives the percentage.
Config1 example:
500 + 1000 + 1000 = 2500
500 / 2500 = .2
.2 * 100 = 20% chance
I am struggling to find a relatively easy way of doing this in an aggregate.
As a side note: This is a new system so I am able to change how the weights are stored/used if there is a better method.
I ended up using the solution discussed here, although it was not in MongoDB, but rather my nodejs micro-service used to return the configuration files.
How to choose a weighted random array element in Javascript?

Percentage of total changes on applying filter

I have a data table with three dimensions and one measure. For each row, I am trying to calculate the percentage of total (calculated by taking the sum of rows) using a calculated field.
As seen in the screenshot attached, For the column titles 'Dec-19' I want the values to be a percentage of current value / grand total (calculated at the bottom as 122,187)
Screenshot of DataTable:
So e.g. for the Column B value of 2000, the Dec-19 column should be (97/122,187) * 100 = 0.079.
I have achieved this by creating a calculated field with the formula: SUM (sales) / MAX ({EXCLUDE (Column B): Sum (sales}), where sales is the measure used in the datatable.
However, upon application of filter on column B, the percentage value changes. e.g. if I select the value 2000 in my filter for column B, I get the percentage as 100%. It seems as if the percentage is being calculated based on only the rows in the filter.
Since you haven't included any sample data, I created some sample data like this, hope this resemble yours.
Thereafter, I built a cross-tab view in tableau, somewhat like yours
If that is the scenario, use a calculated field, say CF like this, instead of yours
([Sales])/
{FIXED [Col1], DATETRUNC('month', [Col3]) : sum([Sales])}
Dragging it in the view
and thus, filtering won't affect your calculation

Crystal Reports: Need to get percentages from Running Total distinct counts

I have a pre-existing Crystal Report that an end-user wants me to add percentages to. I'm running into an issue because the numbers they want percentages of are Running Total distinct count fields with their own formulas.
At the end of a report, I have several Running Total fields that are distinct counts for cars, one field for a count of each color car. The sum of all of these fields equals a grant total of all cars. So it looks something like this:
Black: 5
Red: 10
Green: 5
Yellow: 20
Total: 40
Each of the car color Running Total distinct count fields has a formula behind it to give us the number for that color, and then the "Total" field is just the distinct count of all cars - no formula. I need to automatically calculate and add the percentages of each of the car color rows towards the total count. It would look like this:
Black: 5 12.5%
Red: 10 25%
Green: 5 12.5%
Yellow: 20 50%
Total: 40
At this point I've tried using the existing formulas used to get the car color counts to next inside a new formula that would divide it by the car total, but I can't seem to get the result I want.
After working with this for some additional time, I was able to find the solution. I created a new formula for each of the car colors and was able to divide using the Running Total distinct count field for each, and then times by 100 to move the percentage 2 decimal places. So an example of a formula was:
{BLACK CARS}/distinctcount({Command.CARS}) * 100
I created one of these for each car color and placed them next to the distinct count fields.

How to use only certain number of rows per category for calculation?

I do a simple project where I calculate how many times a ball in casino roulette game lands in each pocket after after 20000 spins.
I have data for 2 different roulette tables with approx 10k spin results for each. I count a number of occurrences of each result which is fine.
The problem arises when I want to limit the calculation to lets say 5k results (rows of data) for each category (Roulette name in this case) and see how many times the ball land in each pocket after 5k spins.
How do I limit how many rows of data per each category do I pass to COUNT() function?
Example of my wb as an img
Try this:
You will have to add a pk field for each of your results so your pk will be 1-10000 or however many records you have.
Parameter Setup:
Choose pk from the Set From Field options
Create a calculated field named N Results
N Results:
IF (pk - 1) < [View for N Results] THEN [result] END
Add N Results to your filter shelf and Exclude NULL. Show View for N Results parameter and type in a value. Your grand total should now equal the parameter value.
Final Layout:
Let me know how that turns out.