How to facet based on dynamic price fields or priceranges - search

I have the some fields in my solr document like
default_price : 100.0,
seg_price_1 : 90.0,
seg_price_2 : 88.0,
seg_price_3 : 75.0
out of these prices i have to consider the minimum price to be given based on the segments user belong to.
for example : if user1 belongs to segment 1 and 2 then the price would be min(default_price,seg_price_1,seg_price_2)
and if user2 belongs to segments 2 and 3 then the price shown to him would be min(default_price,seg_price_2,seg_price_3)
now showing this price is not a problem neither is sorting. The problem is i want to facet based on these fields. Originally we have a field called price_range.
price_range: "100-500"
this field is a string and points to the default price. we use this field in the faceting logic to calculate the count of products belonging to each pricerange.
but now the users could be part of any combination of segments or not part any segment at all(default).
So now since price shown is dynamic based on the segments a particular user belongs to the counts based on faceting the price_range field would be wrong. Also we are getting this price_range field from another team and not a field we can afford to calculate runtime for each record for each user.
So to display the correct counts based on the dynamic prices shown to a user, what is the best way to handle this?
Please suggest.

Related

NetSuite formula to show quantity ordred on first order

We have a saved search in place that displays date of first order and last order by customer & item within a given date range. For example - Looking at sales for May 2022 - today, it shows the item, the customer, the date they first ordered the item, and the date they last ordered the item.
I am now also trying to incorporate the quantity ordered on the first order.
crietera
results
I've tried the following, but keep getting an invalid expression. Can anyone advise on how I might be able to display the qty on the date of the first order?
MIN(CASE WHEN {custbody_reporting_ship_date} THEN {quantity} END)
and
CASE WHEN (MIN({custbody_reporting_ship_date})THEN {quantity} END)
I think this can't be achieved in saved search via simple formula. You may want to try below, what I will do is try to record the first and last order id in the customer record, then from customer saved search you can source from these order fields to the order details.
Create 2 custom entity fields applied to customer
first order id => Type:List/Record => List/Record:Transaction
last order id => Type:List/Record => List/Record:Transaction
Create 1 saved search to get the first order id per customer
Similar to the one that you created, the result field just need the customer internal id and min(document number) and filter need to add customer.internal id
Create 1 saved search to get the last order id per customer
Similar to the one that you created, the result field just need the customer internal id and max(document number) and filter need to add customer.internal id
Create 2 scheduled workflows, to update the first order id and last order id fields in respective customer record.
Create your first and last order customer Saved Searches using the 2 custom fields to source for the order details.
Not sure if this help.

Duplicate results in NetSuite Contact search

Can someone help me understand why I get duplicate results on a Contact search in NetSuite only when I include a Customer field as a result column? Below are steps for how I am reproducing this problem.
Create a new Contact search
Add a single criterion: Internal ID is any of 230, 597, 1808
For results, return just a single column, Internal ID
Submit the search. 3 results are returned as expected (screenshot below).
Return to the criteria for the search
For results, add a second column, Customer : Internal ID
Submit the search again. This time six (6) results are returned (screenshot below).
What is incredible to me is not only are there double the number of results, but the results actually appear to be unique based on the fact that the Customer : Internal ID values are different. What causes this behavior?
It depends upon the field you give as result. If you many number of field in the result section, each result field that match your search criteria or filter will be shown irrespective of what is already displayed(ie,duplicates will be shown).
Use criteria to filter it out or reduce the result field
This is a similar interaction to the "main line" criteria on a transaction search. a contact is a record in itself. When searching for a contact it returns a singular one. As soon as you tell it to return an internal ID of a related document or customer you will find that sometimes a contact can exist in two places at once. So your second set of results basically says that (for example) Contact 597 is connected to customer 168 and customer 167. Contact records are not the same as a customer record.
Each contact has its own internal id, however, the same contact might show up to different records because NetSuite allows you to attach a contact to more than one customers/sub-customers. Therefore when you add customer: internal id it's pulling out all the customers that have the same contact on their records. You can add another column that shows the customer name/id under results and see if this is what happened.

Azure Search min max values

I have an index that is populated with Products. Each product has price field. I want to implement facet navigation on categories pages and i want my users to be able to search for products within a price range. At the same time, I want them to know what the minimum and maximum product price is across products in selected category. As i know Azure Search does not support min/max values in responses. So i am looking for some work around. I think that i can mark my price field as facetable and get min and max value from facet result, but default facet results count is 10, and if i understand correctly to get all prices from facet result i need to set count to Int.Max or something. That does not sound nice.
So what is the best solution to get min and max product price in specific category?
More direct approach to get the min and max product prices would be using $filter, $orderBy and $top in a Search request.
For example,
https://[service name].search.windows.net/indexes/products/docs?search=*&$filter=productName eq 'Toys'&$orderBy=price asc&$top=1.
You will need to parse the price in the response.
The approach using facet would be more expensive and, as you said, can only get you an approximation because boundaries of each facet is from pre-configured range.
Nate

DAX Rank by Date

I am Counting on Distinct ID's in a column - this is leading to the sum of the subtotals not equalling the grand total as follows:
What I want to do is rank the Payment Dates in cronological order and select ONLY the highest date to display. In the example above the Grand Total won't change, but the Townville row will not show a Distinct Student Count.
This is a very specific requirement and I'm assuming there's an easy way to do it in DAX - I've tried playing around with both RANKX and MAX but am no closer to solving this.
One last thing - the Rank must be contextual to the Time Filter selected by the user (so if they select 2015 it'd give the second record Rank 1 and the top record wouldn't show. If they select May 2015 it'd give the top record Rank 1 and the second record wouldn't show)
I think this is what you are looking for - I added a calculated column to the PowerPivot model that provides a rank based on the Last Payment Date and the Name of the Student. It will rank the earliest payment for any student as a 1.
The code for the column is as follows:
=RANKX(FILTER(Table1, [Student Name] = EARLIER([Student Name])), [Last Payment Date])
... assuming your table is named "Table1"!
The FILTER is the key that limits the ranking to dates belonging to students with that name only.
Update for Multiple tables
To set up relationships between the tables, go to the "Diagram View" of the model, available in the Home tab of the Power Pivot window.
You can drag fields from one table to the other to create relationships. This will only work if at least one of the fields is unique - it's a good idea to think of the model as a dimensional model, with a tables that acts like a fact and other tables around it that act like dimensions.
From the comment, I would try to get the Payments to act like the fact, and have it link to the Community and Student tables. in this case, you could then have the following code:
=RANKX(FILTER(Table1, Related('Students'[Student Name]) = EARLIER('Students'[Student Name])), [Last Payment Date])
This calculated column would be on your Payments Fact table, and it uses a lookup to a related field.
Note that in this specific case, it would be easier to just run the filter over your Student ID field that is used to lookup the Student name.

Backbone collection and model structure

I have an app in backbone that has essentially 3 main components: groups, users, and posts. I have models and collections for all 3, and then on top of that I am tracking in depth analytics for each type. Multiple users belong to a single group by the way.
For example, I have another collection called groups_index that has the fields: date, average # of posts, and average post length ( with a new row for each date ). And then I also have a user_index collection that has the fields: date, group_id, average # of posts, and average post length.
I want to be able to generate charts that show the average number of posts for a group across time and the same for the users of a specific group.
Does it make more sense to combine everything into the groups_index collection and add an user_id field? Or would that over-complicate it when showing the group average charts?

Resources