Struggling to find rank values from highest to lowest, please see attached example of what I'm trying to achieve.
My current custom expression is:
Sum([ViolationAmt])
I have tried this:
Sum([ViolationAmt]) over Rank([ViolationAmt])
I've played around with the rank expressions however unable to implement...would be very grateful for some help.
Spotfire Rank Example
I need to make a lot of assumptions here because I don't know anything about your data set or really what your end goal is, so please comment back and/or provide more info in your question if I am off base.
the first assumption is that each row in your dataset represents one, for simplicity, [AccountID] with a [ViolationAmt]. I'm also guessing you want to show the top N accounts with the highest violations in a table, since that's what you've shown here.
so it sounds like you are going to need two calculated columns: one for getting the total [ViolationAmt] per account, and then another to rank them.
for the first, create a column called [TotalViolationAmt] or somesuch and use:
Sum([ViolationAmt]) OVER ([AccountID])
for the second:
Rank([TotalViolationAmt])
it will be useful to read the documentation on ranking functions if you haven't already.
you could probably combine these two into a single column with something like:
Rank(Sum([ViolationAmt]) OVER ([AccountID]))
but I haven't tested this at all. again, if you put in a bit more detail about what you're trying to accomplish it will help you get a better, more detailed answer :)
Related
Im trying to learn bourbon-neat, came across its breakpoint feature that takes a query and grid-columns. What is the use of grid-columns there? Why would you set the grid-columns like that when you can change the columns on the fly with declaration to span-columns?
Just need abit more explanation as to why you will provide a second parameter.
It is just to provide a little more flexibility. You may never use it, but for instance you may wish to have a 12 column grid for large screens and a 5 column grid for smaller columns. In this instance span-columns would not work as 12 cannot be divided by 5.
Admittedly you may not use it that often!
For a school project I am attempting to write what is described as an "interactive diagnosis environment" using prolog. The user will enter a symptom, and a list of diseases that match the symptom will be printed to the screen. The user will then list another symptom, and diseases will be removed from the previous list if they do not match the second symptom, forming a new list. The new list is then printed.
example user input:
SYMPTOM_IN(fever, 150).
SYMPTOM_IN(vomiting, 1).
A list of possible diseases is printed after each input.
This process is repeated until a diagnosis is made or until it is somehow determined that it can't, at which point tests will be suggested and the user can input data regarding the tests in a similar manner, ultimately arriving at a diagnosis.
So far, all I have is a list of facts that will compile and that I can then interact with, but I really don't understand how I am supposed to carry over the list of diseases from one input to the next. I also don't understand how to move from taking symptom input to suggesting tests, although maybe that will be evident once I understand how to do the symptom input portion.
I would really appreciate any help.
Thanks.
EDIT:
Could I take the two values from the SYMPTOM_IN call, use them to do something like symptom(X, fever, 150)., and assert the output from that to store it (like in the answer to this question)? Then maybe I can do the same thing for the next call and take the union of the two lists?
You want to create an expert system. There is a lot of info about it on the net. For example:
https://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_17.html
http://www.amzi.com/ExpertSystemsInProlog/02usingprolog.php
There is also a lot of good info on Stack Overflow.
In short: you need to know how to use assert and retract in proper way.
My problem is to find the titles and each of the last name of the first author of all articles.I have an assignment on xpath and this is the last question i've been banging my head for over an hour but i can't figure it out. Thanks for the help.
The first thing you need to do is find all of the articles. Now we can either do this knowing their specific position in the tree - /Publications/Proceedings/Article - or find all the Articles, wherever they are - //Article. However, this gives us too much infromation and needs to be narrowed down.
What we need is two pieces of information, the title of the article and the last name of the first Author.
Getting the title, is easier as from the Article, we can just grab the title, like so: Article/Title.
To get the Author information is slightly harder, the lastname of anygiven Author can be done like: Author/Surname, however we need one one Author.
To get the first Author of any given article, we can just use the position() function to grab the first one ( remembering that XML array indexing starts at 1): Author[position()=1]. We can shortcut this by just using the number itself - Author[1]
From here you have enough information to build the two XPaths you need. Good luck.
I am new at the idea of programming algorithms. I can work with simplistic ideas, but my current project requires that I create something a bit more complicated.
I'm trying to create a categorization system based on keywords and subsets of 'general' categories that filter down into more detailed categories that requires as little work as possible from the user.
I.E.
Sports >> Baseball >> Pitching >> Nolan Ryan
So, if a user decides they want to talk about "Baseball" and they filter the search, I would like to also include 'Sports"
User enters: "baseball"
User is then taken to Sports >> Baseball
Now I understand that this would be impossible without a living - breathing dynamic program that connects those two categories in some way. It would also require 'some' user input initially, and many more inputs throughout the lifetime of the software in order to maintain it and keep it up to date.
But Alas, asking for such an algorithm would be frivolous without detailing very concrete specifics about what I'm trying to do. And i'm not trying to ask for a hand out.
Instead, I am curious if people are aware of similar systems that have already been implemented and if there is documentation out there describing how it has been done. Or even some real life examples of your own projects.
In short, I have a 'plan' but it requires more user input than I really want. I feel getting more info on the subject would be the best course of action before jumping head first into developing this program.
Thanks
IMHO It isn't as hard as you think. What you want is called Tagging and you can do it Automatically just by setting the correlation between tags (i.e. a Tag can have its meaningful information plus its reation with other ones. Then, if user select a Tag well, you related that with others via looking your ADT collection (can be as simple as an array).
Tag:
Sport
Related Tags
Football
Soccer
...
I'm hoping this helps!
It sounds like what you want to do is create a tree/menu structure, and then be able to rapidly retrieve the "breadcrumb" for any given key in the tree.
Here's what I would think:
Create the tree with all the branches. It's okay if you want branches to share keys - as long as you can give the user a "choice" of "Multiple found, please choose which one... ?"
For every key in the tree, generate the breadcrumb. This is time-consuming, and if the tree is very large and updating regularly then it may be something better done offline, in the cloud, or via hadoop, etc.
Store the key and the breadcrumb in a key/value store such as redis, or in memory/cached as desired. You'll want every value to have an array if you want to share keys across categories/branches.
When the user selects a key - the key is looked up in the store, and if the resulting value contains only one match, then you simply construct the breadcrumb to take the user where you want them to go. If it has multiple, you give them a choice.
I would even say, if you need something more organic, say a user can create "new topic" dynamically from anywhere else, then you might want to not use a tree at all after the initial import - instead just update your key/value store in real-time.
I have a list of airport names and my users have the possibility to enter one airport name to select it for futher processing.
How would you handle misspelled names and present a list of suggestions?
Look up Levenshtein distances to match a correct name against a given user input.
http://norvig.com/spell-correct.html
does something like levenshtein but, because he doesnt go all the way, its more efficient
Employ spell check in your code. The list of words should contain only correct spellings of airports.
This is not a great way to do this. You should either go for a control that provides auto complete option or a drop down as someone else suggested.
Use AJAX if your technology supports.
I know its not what you asked, but if this is an application where getting the right airport is important (e.g. booking tickets) then you might want to have a confirmation stage to make sure you have the right one. There have been cases of people getting tickets for the wrong Sydney, for instance.
It may be better to let the user select from the list of airport names instead of letting them type in their own. No mistakes can be made that way.
While it won't help right away, you could keep track of typos, and see which name they finally enter when a correct name is entered. That way you can track most common typos, and offer the best options.
Adding to Kevin's suggestion, it might be a best of both worlds if you use an input box with javascript autocomplete. such as jquery autocomplete
edit: danish beat me :(
There may be an existing spell-check library you can use. The code to do this sort of thing well is non-trivial. If you do want to write this yourself, you might want to look at dictionary trie's.
One method that may work is to just generate a huge list of possible error words and their corrections (here's an implementation in Python), which you could cache for greater performance.