It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Opencart having performance issue and takes time to load when the number of category is high, currently i am having 250+ categories and around 5000 products. anyone help...
Have you tried any of the category count removals? That seems to be the answer to most. if not, then a page cache mod is what you need. Note that you will need vQmod to be able to use both of those
Test your page at http://gtmetrix.com
Reduce image size and check needed quality.
Check your .htaccess for expireheaders on images and script.
Add last to file:
#Expire Header
<FilesMatch "\.(js|css|swf)$">
ExpiresDefault "access plus 2 week"
</FilesMatch>
or
# enable expirations
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType image/gif "access plus 2 week"
ExpiresByType image/png "access plus 2 week"
ExpiresByType image/jpeg "access plus 2 week"
ExpiresByType image/jpg "access plus 2 week"
ExpiresByType image/pjpeg "access plus 2 week"
ExpiresByType text/javascript "modification plus 2 week"
ExpiresByType application/javascript "modification plus 2 week"
ExpiresByType text/css "modification plus 2 week"
Related
I have two tables one with data about franchise locations (Franchise Profile Info) and one with Award data. Each franchise location is given a certain number of awards they are allowed to give out per year. Each franchise location rolls up to a larger group depending on where in the country they are located. These tables are in a 1 to 1 relationship using Franchise ID. I am trying to create a matrix with the number of awards, total utilized, and percentage utilized rolled up to group with the ability to expand the groups and see individual locations. For some reason when I add the value fields a blank row is created. There are not any blank rows in either of the original tables so I'm not sure where this is coming from.
Franchise Profile Info table
ID
Franchise Name
Group
Street Address
City
State
164
Park's
West
12 Park Dr.
Los Angeles
CA
365
A & J
East
243 Whiteoak Rd
Stafford
VA
271
Otto's
South
89 Main St.
St. Augustine
FL
Award table
ID
Year
TotalAwards
Utilized
164
2022
16
12
365
2022
5
5
271
2022
22
17
This tables are in a relationship with a 1 to 1 match on ID
What I want the matrix to look like
Group
Total Awards
Utilized
%Awards Utilized
East
5
5
100%
West
16
12
75%
South
22
17
77%
Instead what I'm getting is this
Group
Total Awards
Utilized
%Awards Utilized
East
5
5
100%
West
16
12
75%
South
22
17
77%
0
0
0%
I can't for the life of me figure out where this row is coming from. I can add in the Group and Franchise name as rows but as soon as I add any of the value columns this blank row shows up.
You have a value on the many side that does not exist on the one side. You can read a full explanation here. https://www.sqlbi.com/articles/blank-row-in-dax/
My code below produces the graph attached. However, I am trying to add two adjustments but with no luck.
1- I would like to organize the Y axis where for all industries November comes before December, rather than being arranged by which month had more jobs as in the current graph.
2- I also tried adding labels to the Y axis where it only says "Nov" & "Dec", without the additional text, and while Stata does not produce any errors, it is not changing the graph.
preserve
drop if total_jobs_industry<15
graph hbar (count) total_jobs_industry, over(month) over(industry, sort(1)) subtitle("Jobs by Industry and month", span)
restore
I know that I can change the graph with tiny details manually in Stata, but I prefer automating the process if possible.
Data example:
Example generated by -dataex-. To install: ssc install dataex
clear
input float total_jobs_industry str39 industry str8 month
11 "Architectural & Engineering Services" "Nov_2020"
11 "Architectural & Engineering Services" "Nov_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Nov_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Nov_2020"
38 "Computer Hardware & Software" "Dec_2020"
12 "Consulting" "Dec_2020"
63 "" "Dec_2020"
32 "IT Services" "Dec_2020"
32 "IT Services" "Nov_2020"
38 "Computer Hardware & Software" "Nov_2020"
12 "Aerospace & Defense" "Nov_2020"
12 "Accounting" "Nov_2020"
12 "Accounting" "Dec_2020"
When I ran with sum, instead of count, I get the graph below:
preserve
drop if total_jobs_industry<15
graph hbar (sum) total_jobs_industry, over(month) over(industry, sort(1)) subtitle("Jobs by Industry and month", span)
restore
Furthermore, this is how I create the variable to the count the number of jobs per industry:
// The variable id contains observation number running from 1 to X and nt is the total number of observations
generate id = _n
generate nt = _N
// Sorting by inudstry. Now n1 is the observation number within each Industry group and total_jobs_industry is the total number of observations for each Industry group.
sort industry
by industry: generate n1 = _n
by industry: generate total_jobs_industry = _N
order total_jobs_industry, a(industry)
This is a very puzzling question. The following list of reasons is not complete.
The post seems to mix old and new versions of itself and isn't consistent. You can not reasonably expect us to decode such a meandering story reliably. The standard here is to present a minimal verifiable example, and that standard is not being met by this thread. See guidance here.
Neither of the graphs shown correspond to the data given.
It is hard for me to believe that (count) makes sense for your data. As said, it counts non-missing values, but your key variable appears to be total_count_industry. On the other hand, working variously with (sum) and the number of observations seems to confuse quite different kinds of calculations.
There appear to be duplicate observations in your example data.
You state that you ' also tried adding labels to the Y axis where it only says "Nov" & "Dec" ' but nothing in your code shows any such attempt to comment on.
You're expecting Nov_2020 to sort before Dec_2020, which won't happen because so far as Stata is concerned it is just a string variable, so the fact that D sorts before N is paramount. This is the reason December sorts before January, and it's nothing to do with sorting on industry values, which affects only the ordering of the groups of bars. You're not making use of Stata's functionality for date variables.
I doubt that I can make sense of any of these problems except the last. It seems to be a limitation of graph hbar that it ignores time variable display formats, so I used value labels to ensure that Nov and Dec sort in the order you wish.
clear
input float total_jobs_industry str39 industry str8 month
11 "Architectural & Engineering Services" "Nov_2020"
11 "Architectural & Engineering Services" "Nov_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Nov_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Dec_2020"
11 "Architectural & Engineering Services" "Nov_2020"
38 "Computer Hardware & Software" "Dec_2020"
12 "Consulting" "Dec_2020"
63 "" "Dec_2020"
32 "IT Services" "Dec_2020"
32 "IT Services" "Nov_2020"
38 "Computer Hardware & Software" "Nov_2020"
12 "Aerospace & Defense" "Nov_2020"
12 "Accounting" "Nov_2020"
12 "Accounting" "Dec_2020"
end
duplicates drop
gen mdate = monthly(month, "MY")
levelsof mdate, local(months)
tokenize "`c(Mons)'"
foreach m of local months {
local month = month(dofm(`m'))
label def mdate `m' "``month''", modify
}
label val mdate mdate
set scheme s1color
graph hbar (asis) total_jobs_industry, over(mdate) over(industry, sort(1) descending)
I should be able to make a report concerning a relationship between sick leaves (days) and man-years. Data is on monthly level, consists of four years and looks like this (there is also own columns for year and business unit):
Month Sick leaves (days) Man-years
January 35 1,5
February 0 1,63
March 87 1,63
April 60 2,4
May 44 2,6
June 0 1,8
July 0 1,4
August 51 1,7
September 22 1,6
October 64 1,9
November 70 2,2
December 55 2
It has to be possible for the user to filter year, month, as well as business unit and get information about sick leave days during the filtered time period (and in selected business unit) compared to the total sum of man-years in the same period (and unit). Calculated from the test data above, the desired result should be 488/22.36 = 21.82
However, I have not managed to do what I want. The main problem is, that calculation takes into account only those months with nonzero sick leave days and ignores man-years of those months with zero days of sick leaves (in example data: February, June, July). I have tried several alternative functions (all, allselected, filter…), but results remain poor. So all information about a better solution will be highly appreciated.
It sounds like this has to do with the way DAX handles blanks (https://www.sqlbi.com/articles/blank-handling-in-dax/). Your context is probably filtering out the rows with blank values for "Sick-days". How to resolve this depends on how your data are structured, but you could try using variables to change your filter context or use "IF ( ISBLANK ( ... ) )" to make sure you're counting the blank rows.
I have a table that contains data for 13 prior month ends as well as the most recent business day. The majority of my reports only look at a single period at a time so I have a slicer on each report to allow the user to choose the period they want to look at, which is generally the most recent business day. Whenever the data gets refreshed I have to manually go to each slicer that had the most recent business day selected and choose the new most recent business day (unfortunately my organization hasn't updated to the version that allows the slicers to be synced). As we move towards production and scheduled refreshes, this will be a nuisance so I added a second column called REPORTING_DATE, which is equal to the original DATA_DATE field except the most recent date is replaced with 'Most Recent' so any slicers with that selected can maintain their selection after a refresh.
This is a simplified example of my data:
DATA_DATE REPORTING_DATE ACCOUNT_NO
7/10/2018 Most Recent 1001
7/10/2018 Most Recent 1002
7/10/2018 Most Recent 1003
7/10/2018 Most Recent 1004
7/10/2018 Most Recent 1005
7/10/2018 Most Recent 1006
7/10/2018 Most Recent 1007
6/30/2018 6/30/2018 1001
6/30/2018 6/30/2018 1002
6/30/2018 6/30/2018 1003
6/30/2018 6/30/2018 1004
6/30/2018 6/30/2018 1005
6/30/2018 6/30/2018 1006
5/31/2018 5/31/2018 1001
5/31/2018 5/31/2018 1002
5/31/2018 5/31/2018 1003
5/31/2018 5/31/2018 1004
My issue is that when I change my slicer to use DATA_DATE instead of REPORTING_DATE it breaks my measure that I use to calculate the change in counts for each period.
Change in Count (Month) = DISTINCTCOUNT(MyData[ACCOUNT_NO])-CALCULATE(DISTINCTCOUNT(MyData[ACOUNT_NO]),PARALLELPERIOD(MyData[DATA_DATE],-1,MONTH))
When my slicer has DATA_DATE = 7/10/2018 the measure correctly returns 1 (count of 7 for July 10 minus a count of 6 for June 30). When I use a slicer with REPORTING_DATE = Most Recent I get 7 because DISTINCTCOUNT(MyData[ACCOUNT_NO]) returns 7, which is correct, but CALCULATE(DISTINCTCOUNT(MyData[ACOUNT_NO]),PARALLELPERIOD(MyData[DATA_DATE],-1,MONTH)) returns (Blank). It looks like PARALLELPERIOD(MyData[DATA_DATE],-1,MONTH) returns the same value 6/30/2018 regardless of the slicer being used so I'm stumped as to the issue.
The reason this does not work is that the PARALLELPERIOD filter in your CALCULATE is only replacing the context filter for the [DATA_DATE] column but still has the slicer filtering in effect since that is on a different column. If you select Most Recent on the [REPORTING_DATE] slicer, your measure will try to find the distinct count where [REPORTING_DATE] is Most Recent and also [DATA_DATE] is in the previous month. Since no such rows exist, it returns a blank.
To fix this, you can tell the measure to ignore the filtering directly from the [REPORTING_DATE] slicer and only use the filtering on the [DATA_DATE] column (which gets indirectly filters from the slicer).
Change in Count (Month) =
DISTINCTCOUNT(MyData[ACCOUNT_NO]) -
CALCULATE(
DISTINCTCOUNT(MyData[ACOUNT_NO]),
ALL(MyData[REPORTING_DATE]),
PARALLELPERIOD(MyData[DATA_DATE], -1, MONTH))
The reason that this works with the slicer on [DATA_DATE] is that the PARALLELPERIOD filter replaces the slicer filtering for that column. When you slice on [REPORTING_DATE], the slicer filtering does not get replaced since you aren't referring to that column inside a CALCULATE filter argument.
If this still doesn't make sense, I recommend some reading on how the CALCULATE function works. There's an entire chapter devoted to it in The Definitive Guide to DAX and there's a handful of websites/blogs that have some decent reading too.
I'm writing my master thesis on the costs of occupational injuries. As a part of the thesis I have estimated the expected wage loss for each person for every year for four years after the injure. I would like to discount the estimated losses to a specific base year (2009) in SAS.
For the year 2009 the discounted loss is just equal the estimated loss. For 2010 and on the discounted loss can be calculated with the netpv function:
IF year=2009 then discount_loss=wage;
IF year=2010 then discount_loss=netpv(0.1,1,0,wage);
IF year=2011 then discount_loss=netpv(0.1,1,0,0,wage);
And so forth. But starting from 2014 I would like to use the estimated wage loss for 2014 as the expected loss onward - so for instance if the estimated loss is 100$ that would represent the yearly loss until retirement. Since each person don't have the same age there would be too many ways just to hard code, so I'm looking for a better way. There are approximately 200.000 persons in my data set with different estimated losses for each year.
The format of the (fictional) data looks like this:
id age year age_retirement wage_loss rate discount_loss
1 35 2009 65 -100 0.1 -100
1 36 2010 65 -100 0.1 -90,91
1 37 2011 65 -100 0.1 -82,64
1 38 2012 65 -100 0.1 -75,13
1 39 2013 65 -100 0.1 -68,30
1 40 2014 65 -100 0.1
The column discount_loss is the net present value of the loss i 2009. Calculated as above.
I would like the loss in 2014 to represent the sum of losses for the rest of the period (until age_retirement) on the labor market. That would be -100$ discounted for 2009 starting from 2014 until 2014+(65-40).
Thanks!
Use the FINANCE function for PV, Present Value.
In your situation above, you're looking for the value of 100 for 25 years of payments (65-40)=25. I'll leave the calculation of the number of years up to you.
FINANCE('PV', rate, nper, payment, <fv>, <type>);
In your case, Future Value is 0 and the type=1 as you assume payment at the beginning of the year.
The formula below calculates the present value of a series of 100 payments over 25 years with a 10% interest rate and paid at the beginning of the period.
value=FINANCE('PV', 0.1, 25, -100, 0, 1);
Value = 998.47440201
Reference is here:
https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p1cnn1jwdmhce0n1obxmu4iq26ge.htm
If you are looking for speed why not first calculate an array that contains the PV of $1 for for i years where i goes from 1 to n. Then just select the element you need and multiply. This could all be done in a data step.