I have some data (pictured below) that gives the sum of sales for each Canadian province in a table. Clearly from the data Newfoundland has the lowest sales ($102,924) and Ontario has the highest ($3,063,212). I'd like to incorporate this information (these min/max values) into a gauge but I want to use a formula, I don't want to just hardcode the values in case the data changes in the future.
In my load script I let variables vMin and vMax be defined as follows:
Let vMax ='Max(ggr(sum(Sales,Province))'; //should correspond to Newfoundland
Let vMin ='Min( aggr(sum(Sales),Province))'; //should correspond to Ontario
I'm getting some unexpected behavior. It appears that Qlik is calculating this formula based on my selections. In QlikView you can use triggers but I'm using Qliksense Desktop. Is there a way around this in QlikSense Desktop?
You can try looking at the whole data set and ignoring what's selected by using {1} in your aggregation.
Let vMax ='Max(aggr(sum({1} Sales),Province))';
Let vMin ='Min(aggr(sum({1} Sales),Province))';
Here's the answer that worked for me if anyone is interested:
Max({1} aggr(sum({1} Sales),Province))
Related
I would like to find the distance between 2 points using Lat,Long in microsoft access.
The formula can give the result what I want but when I filter by putting condition, for example <3km or <=5km, there is always error shows 'Division by zero'.
I was trying to use Coalesce cover over Sqr part but still the same error show up
May I know which part of the equation become zero?
DIST_Km: Round(((Atn(-(Cos((3.14*(90-[LOC_22AUG2022_1]![Lat]))/180)*Cos((3.14*(90-[LOC_22AUG2022]![Lat]))/180)+Sin((3.14*(90-[LOC_22AUG2022_1]![Lat]))/180)*Sin((3.14*(90-[LOC_22AUG2022]![Lat]))/180)*Cos((3.14*([LOC_22AUG2022_1]![Lon]-[LOC_22AUG2022]![Lon]))/180))/(Sqr(-(Cos((3.14*(90-[LOC_22AUG2022_1]![Lat]))/180)*Cos((3.14*(90-[LOC_22AUG2022]![Lat]))/180)+Sin((3.14*(90-[LOC_22AUG2022_1]![Lat]))/180)*Sin((3.14*(90-[LOC_22AUG2022]![Lat]))/180)*Cos((3.14*([LOC_22AUG2022_1]![Lon]-[LOC_22AUG2022]![Lon]))/180))*(Cos((3.14*(90-[LOC_22AUG2022_1]![Lat]))/180)*Cos((3.14*(90-[LOC_22AUG2022]![Lat]))/180)+Sin((3.14*(90-[LOC_22AUG2022_1]![Lat]))/180)*Sin((3.14*(90-[LOC_22AUG2022]![Lat]))/180)*Cos((3.14*([LOC_22AUG2022_1]![Lon]-[LOC_22AUG2022]![Lon]))/180))+1)))+2*Atn(1))*6371),2)
[1]: https://i.stack.imgur.com/FYgSp.png [1]
I've included a link to an image of the head of my dataframe. As you can see, the prices column has periods, commas, dollar signs, as well as prices in different currency.
I would like to iterate through all the elements in the prices column and remove everything except for numbers. Moreover, the only number I want is the number that shows the price of an object in Canadian currency.
Here is the code I've tried
df['prices']=df['prices'].map(lambda x: x.strip('.,'))
This didn't work. I've also tried the following
df['prices']=df['prices'].map(lambda x: x.lstrip('.,').rstrip('CA'))
which also didn't work.
What would you suggest I do? If you could also explain why you use the code that you use, then that would help me immensely in learning the Python language. :)
Try using:
df['prices']=df['prices'].apply(lambda x: re.sub('[^0-9]+', ‘’, x))
Edit: I missed the part where you said you want just the canadian currency. So assuming the the middle part (CA1234) is the format for canadian currency,
df['prices']=df['prices'].apply(lambda x: float(x.split(“,”)[1][2:]))
I defined the following equation to calculate the sum of total power consumed by the system:
TotalPower.. systemPower =e= sum(J,P(J)) + sum(I,CP(I));
However, the variable systemPower gets only the result of the second sum and not both!. The declaration of P(J) is as following:
P.LO(I)=0;
P.up(I)=100;
P.l('i1')=2;
P.l('i2')=3;
Please, Can any one explain why I get the result of a single sum? How I can do to get both?. I tried also to separate them in different values but yet I get the same result.
Thank you in advance.
I though it is a good idea to share this it might help someone else. I used a variable directly instead of an equation and I put it in the following form and it worked.
systemPower.l = sum(I,P.l(I))+sum(I,CP(I));
My dataset has WeekEndingDate and Sales. I am displaying a straight table with all the selected data but I need to have another table showing the following:
Sales (other columns...)
First week : 1,000
Last week : 1,350
Difference : 350
Difference %: 35%
My questions:
a) Can I have the above in one chart/table, or I need 4 different charts showing columns filtered by set expressions?
b) My strategy is having 2 variables (vMinWeek and vMaxWeek), and using them in set expressions. Is that the best route?
c) My set expressions (below) are not working - they sum the whole data set. Would you please help me understanding why?
=max ({$<WeekEndingDate={'$(vMinWeek)'}>} Sales)
Thank you for your help!
Mara
I think the reason your set isn't working is that your WeekEnd date is formatted as a date and your variable is formatted as a number.
The trick with Set Analysis is always to think what you would have to type in a list box to get to your answer. So even though QlikView stores WeekEnd 2014/08/18 as 41869 you can't type 41869 in the WeekEnd list box and get back that date. So I would make your variables of the form =date(min(WeekEnd)).
The second part of your question; getting the table you want. I would do like this. I make a loose table with the dimension values, dual is so that it sorts correctly in the chart we are going to build.
load dual(D,N) as DIM inline [
D,N
First Week,1
Last Week,2
Difference,3
Dif %,4
];
I like defining my variables in the script as well, so I would do this.
set vFirstWeek='=date(min(WeekEnd))';
set vLastWeek='=date(max(WeekEnd))';`
Then when building the straight table we use the dimension as DIM but because DIM isn't connected to anything we have to do some work to get it to display values that fit those dimension values. The num(,'# ##0') is just to format the % differently from the sums. For this to work the number format in the Number tab of the chart must be set to Expression Default.
if(DIM='First Week',num(sum({<WeekEnd={'$(vFirstWeek)'}>} Sales),'# ##0'),
if(DIM='Last Week',num(sum({<WeekEnd={'$(vLastWeek)'}>} Sales),'# ##0'),
if(DIM='Difference',num(sum({<WeekEnd={'$(vFirstWeek)'}>} Sales)-sum({<WeekEnd={'$(vLastWeek)'}>} Sales),'# ##0'),
if(DIM='Dif %',num((sum({<WeekEnd={'$(vFirstWeek)'}>} Sales)-sum({<WeekEnd={'$(vLastWeek)'}>} Sales))/sum({<WeekEnd={'$(vLastWeek)'}>} Sales),'0.00%')))))
I have a CCTR-800 Portable GPS tracker and I'm receiving data from it in the following format:
*130622214449UB05CW9999C00017093214449A28.452306052.197705130622129.0111111111L000000^
*130622214449UA010214449A28.452306052.197705130622129.0111111111L000000^
Someone have an ideia of what format is this?
I know that the first numbers are date/time: 13-06-22 21:44:49.
I found it, it's Viczone's protocol:
http://www.gps-profi.ru/tech/Communication_Protocol_for_VIC-T801.pdf
So if you break the line up into segments based on the letters you end up with something like this
*130622 214449 UB05 CW9999 C00017093214449 A28.452306052.197705130622129.0111111111 L000000
*130622 214449 UA010214449 A28.452306052.197705130622129.0111111111 L000000
I would start with getting a list of coordinates or where the points were recorded and try correspond the points you recorded with the data.
The first grouping is going to be date and time
The second grouping UB / UA / CW / C seems to change based on the line. Does it always alternate like that? Do the numbers change based on location?
The third grouping A seems repeatable and may be location data
The last grouping L seems kinda of useless but it could change based on other parameters. Does it always report back 0?
Can you move to the GPS to from point to point (say one end of your room to the other) and get repeatable or similar numbers?
It would be worth a shoot to look up if anyone else has worked with that type of GPS.