"File As" Expression in MS Access Query - ms-access-2013

I have built a query that has expression to create a "File As" field. For the query, I have fields for ParticipantFName, ParticipantLName (combined in "Owner" field) and BusinessName. In the "File As" field, if the "Owner" field is empty, it will add the BusinessName (so it will either show the owner or the business, whichever is filled in) and it works great. Now I'm being asked to add a field for TribeName.
What would the expression be if the owner is empty and the business name is empty to show the tribe name? The expression I have now is
File As: Nz([Owner],[BusinessName])

Consider nesting the NZ() function:
File As: Nz([Owner], Nz([BusinessName], [TribeName]))
Alternatively, use IIF():
File As: IIF([Owner] IS NOT NULL, [OWNER],
IIF([BusinessName] IS NOT NULL, [BusinessName],
IIF([TribeName] IS NOT NULL, [TribeName], NULL)))

Related

Is there a way to compare each item to a aggreated value?

I'm new to graphQL and Hasura. I'm trying(in Hasura) to let me users provide custom aggregation (ideally in the form of a normal graphQL query) and have then each item the results compared against the aggreation.
Here's a example. Assume I have this schema:
USERTABLE:
userID
Name
Age
City
Country
Gender
HairColor
INCOMETABLE:
userID
Income
I created a relationship in hasura and I can query the data but my users want to do custom scoring of users' income level. For example, one user may want to query the data broken down by country and gender.
For the first example the result maybe:
{Country : Canada
{ gender : female
{ userID: 1,
Name: Nancy Smith,..
#data below is on aggregated results
rank: 1
%fromAverage: 35%
}...
Where I'm struggling is the data showing the users info relative to the aggregated data.
for Rank, I get the order by sorting but I'm not sure how to display the relative ranking and for the %fromAverage, I'm not sure how to do it at all.
Is there a way to do this in Hasura? I suspected that actions might be able to do this but I'm not sure.
You can use track a Postgres view. Your view would have as many fields as you'd like calculated in SQL and tracked as a separate "table" on your graphql api.
I am giving examples below based on a simplification where you have just table called contacts with just a single field called: id which is an auto-integer. I am just adding the id of the current contact to the avg(id) (a useless endeavor to be sure; just to illustrate...). Obviously you can customize the logic to your liking.
A simple implementation of a view would look like this (make sure to hit 'track this' in hasura:
CREATE OR REPLACE VIEW contact_with_custom AS
SELECT id, (SELECT AVG(ID) FROM contacts) + id as custom FROM contacts;
See Extend with views
Another option is to use a computed field. This is just a postgres function that takes a row as an argument and returns some data and it just adds a new field to your existing 'table' in the Graphql API that is the return value of said function. (you don't 'track this' function; once created in the SQL section of Hasura, you add it as a 'computed field' under 'Modify' for the relevant table) Important to note that this option does not allow you to filter by this computed function, whereas in a view, all fields are filterable.
In the same schema mentioned above, a function for a computed field would look like this:
CREATE OR REPLACE FUNCTION custom(contact contacts)
RETURNS Numeric AS $$
SELECT (SELECT AVG(ID) from contacts ) + contact.id
$$ LANGUAGE sql STABLE;
Then you select this function for your computed field, naming it whatever you'd like...
See Computed fields

Is it possible to create a CRM workflow that updates "Modified By" field?

I want to create a CRM workflow that updates the "Modified By" field based on a text field called "Prepared By". "Prepared By" contains a user's full name. Is this possible?
When I try to add an "Update Record" step in my workflow, it doesn't seem to let me update the "Modified By" field.
You cannot map a lookup field using a text field value in UI Workflow. I would recommend you to go for code solution. ie. plugin or custom workflow activity - where we can use C# SDK to update the value.
You can do a RetrieveMultiple or below LINQ example for finding the SystemUser record using the text value from the Prepared By attribute & set the ModifiedBy field EntityReference. This can be done in either pre or post operation.
Entity _user = context.CreateQuery("systemuser").Where(e => e.GetAttributeValue<string>("fullname").Equals(fullname)).FirstOrDefault();
if (_user != null)
{
_target["modifiedby"] = _user.ToEntityReference();
}
//assign new target to plugin executioncontext
pluginExecutionContext.InputParameters["Target"] = _target;
Reference

Full-text searth JSON-string

I have a question: in my DB i have a table, who has a field with JSON-string, like:
field "description"
{
solve_what: "Add project problem",
solve_where: "In project CRUD",
shortname: "Add error"
}
How can i full-text search for this string? For example, I need to find all records, who has "project" in description.solve_what. In my sphinx.conf i have
sql_attr_json = description
P.S.Mb i can do this with elasticSearch?
I've just answered a very similar questio here:
http://sphinxsearch.com/forum/view.html?id=13861
Note there is no support for extracting them as FIELDs at this time -
so cant 'full-text' search the text within the json elements.
(To do that would have to use mysql string manipulation functions to
create a new column to index as a normal field. Something like:
SELECT id, SUBSTR(json_column,
LOCATE('"tag":"', json_column)+7,
LOCATE('"', json_column, LOCATE('"tag":"', json_column)+7)-LOCATE('"tag":"',
json_column)-7 ) AS tag, ...
is messy but should work... )
The code is untested.

Evaluate SPListItem field values using debugger

How do I evaluate SPListItem field values using VS debugger? Best I get is only a list of Field names, but not values.
Try this:
oListItem["Assigned To"]
where oListItem is the name of your Item and "Assigned To" is the name of the field.

LINQ - Update null integer data field

I have got a field with data type int? price and allow null, when I set
book.price = null;
and update, it is not saved and does not throw any exceptions, when I change value # null, it is ok. I want set it null.
Make sure the field is nullable in the database and is reflected so in the dbml.
Regenerate the dbml for the table just to be sure. (Drop tabel from dbml and add again)
All I can say is it works for us so this is very strange.
I am not suer I understand the question, this part is unclear:
"when I change value # null, it is ok"
Did you make sure to call
db.SaveChanges();
(where [db] is the name of your Entites object)
It is a simple mistake that I make often :P

Resources