I have a pandas panel of investment pricing data to which I want to add two new minor axis columns (portfolio holding and benchmark holding).
The initial panel is:
<class 'pandas.core.panel.Panel'>
Dimensions: 4 (items) x 463 (major) x 8 (minor)
Items: ListedEquity:BHP Billiton:BHP.AX to SavingsAccount:ING Australia Savings Maximiser
Major axis: 2010-01-04 00:00:00 to 2011-10-31 00:00:00
Minor axis: content_type to xrate
which conceptually looks like:
Investment 1 Investment 2
c1 c2 c3... c1 c2 c3...
Date 1
Date 2
...
Is it possible create a matching panel that only has these columns and then somehow merge the two?
Thoughts on possible alternative ways of achieving this?
The documentation on the Panel data structure is pretty bare.
EDIT:
I created the 2nd panel and tried p1.join(p2) but this generates a columns overlap error.
Here's the 2nd panel I would like to append:
<class 'pandas.core.panel.Panel'>
Dimensions: 4 (items) x 463 (major) x 2 (minor)
Items: ListedEquity:BHP Billiton:BHP.AX to SavingsAccount:Comsec Cash Management Account
Major axis: 2010-01-04 00:00:00 to 2011-10-31 00:00:00
Minor axis: benchmark to portfolio
Sorry I missed this question some time ago. Could you have a look at the new concat function in pandas 0.7.0 and see if it meets your needs:
http://pandas.pydata.org/pandas-docs/stable/merging.html#concatenating-objects
I recently spent a great deal of time on the join and concatenation methods.
Related
I have a table showing Turnover.
I used the same column but did a SUM IIF on the detail lined as follows:
=SUM(IIF(Fields!ID_Country.Value = 17,Fields!Turnover.Value,0))
and
=SUM(IIF(Fields!ID_Country.Value = 23,Fields!Turnover.Value,0))
17 = Great Britain
23 = Ireland
I then want to do a TOTAL per column based on my above detail rows. I just cannot find the right way to do it.
I Tried:
SUM(=SUM(IIF(Fields!ID_Country.Value = 17,Fields!Turnover.Value,0)))
But this does not work.
Please help as I am really stuck.
Thank you!
Because Turnover for GB is in Pounds and for Ireland they are in Euros, I want to split my columns and then do a final SUM for GB and Ireland.
I expect to see the grant total for per column for GB and Ireland summing my detail rows which have the expression calculation. (SUMIIF)
Table: Circled in RED is where I expect to see my TOTAL
enter image description here
Data Structure:
enter image description here
I am trying to retrieve distinct data from 3 different tables.
My query looks like this:
SELECT T.Topic,T.EventNo, T.EventType, T.EventLoc, T.EventDate, T.StartTime, T.EndTime, T.Details, ((ES.SFirstName || ' ' || ES.SLastName))AS SPEAKER
FROM TIMETABLE T
, EXTERNALSPEAKER ES
, SPEAKEREVENT SE
WHERE T.EventNo = SE.EventNo
AND ES.SpeakerID = SE.SpeakerID
AND EventDate >= SYSDATE
ORDER BY EventDate;
The result looks like this:
Normalization by Evaluation for Sized Dependent Types 4 Lecture CH.03.024, FLOOR 1
Normalization by Evaluation for Sized Dependent Types 4 Lecture CH.03.024, FLOOR 1
Careers and Employment Information Workshop 1 Workshop Park Plaza Westminster Bridge Hotel
Object-Oriented Software Design 2 Lecture CH.02.054, FLOOR 3
Doing for our robots what evolution did for us 3 Lecture CH.01.044, FLOOR 4
Doing for our robots what evolution did for us 3 Lecture CH.01.044, FLOOR 4
I have spent hours and I just can't figure it out. I am new to SQL.
Thank you!
We've got too few information to suggest something smart, so here's the most obvious "solution": DISTINCT.
select DISTINCT T.Topic, ...
I am a heavy user of R who is trying to port some basic calculations to Power BI but unable to get DAX to perform vector/rowwise division.
For example, with this dataset:
Category Value
-------- -----
A 1
A 2
B 3
C 4
I have created a measure: Value Sum = SUM(Table[Value])
and I would like to create a third column: Value Share = Value / Value Sum to get:
Category Value Value Share
-------- ----- -----------
A 1 0.1
A 2 0.2
B 3 0.3
C 4 0.4
The equivalent in R would be :
table$Value.Share = table$value/Value.Sum
I have tried: Value Share = [Value] / [Value Sum] but I ended up with 1s in all Value Share rows. Tried SUMX and CALCULATETABLE functions but I believe I am missing something fundamental. Can anyone help?
Sure! If you're starting out with DAX, I can highly recommend to view one of the video lectures of Alberto Cairo / Marco Russo like https://www.youtube.com/watch?v=klQAZLr5vxA, because your question (and all of DAX difficulty) is primarily about contexts.
As for your question, I think you're looking for
=[Value]/CALCULATE(SUM([Value]); ALL(TableName))
Of course, you can replace SUM([Value]) with a measure name too.
See also http://www.daxpatterns.com/cumulative-total/
try this formula: divide([value],sum([value]))
SNAP of DAX formula
I have database where i am calculating the shipping cost. The logic of shipping cost is such way that it is calculated every 500gm. I have price list according to different weight but when i am using calculation taking the weight from user for example 1.4 i am unable to get it to next calculative weight of 1.5 , .7 to 1.0 , 1.7 to 2.0 how to achieve this?
Try this (substitute myNumber to get a different result):
Let (
[
myNumber=2.6;
myNumberInt = INT(myNumber);
myNumberFr = myNumber - myNumberInt;
myNumberFr = Case ( myNumberFr =0;0;myNumberFr >0.5 ; 1;0.5 );
result = myNumberInt + myNumberFr
]
;
result
)
You can wrap it in a custom function, in case you need to change it later throughout the system.
I am sure there is a better mathematical formula, but this should get you started
The Problem is fixed.
I have price list according to weight slab in different table.
I used the Country code with Zone id to track prices for particular weight slab prices provided by the courier company.
The price list for e.g. is in such way :-
Zone 1 .5Kg 100Yuan 1.0Kg 120 yuan etc etc , there goes till 20Kg in some case at max.
so when i input the weight in weight field for e.g. 13.5kg i use this weight / .5 which gives me a value 27 , the reason i use to divide the weight with .5 is for example if i input the weight to 13.8 kg i get 27.6 there upon i embed this in ceiling function in calculation field which gives me value of 28 which i can use to calculate the next price slab in the price list which is for every 500Gms +- .
Once i get this done i use this in script which does the job of going to particular layout to search the zone and the prices and retrieving those data to original layout to show the desired result.
Regards,
Soni
This forum seems to be more geared toward more programming issues but I would be interested if someone would look at the logic issue in the link below.
My issue is about how to calculate the previous 12 months' total using the calendar already defined. I have found very few examples of this on the QV community. Please see the link below for more details. I would be willing to look at an SQL or a QV script solution.
Our fiscal year runs Nov to Oct. I would like to have the end user select the Year and a chart to display the last rolling 12 months' margin. I have had issues getting my total to accumulate for previous months.
My goal would be for it look similar to the Rolling 12 Month Total - GP column in the manually calculated Excel image 'Goal' (look at QV link for screenshot).
Rolling Margin equation: my attempt to use Set Analysis to make a rolling avg equation.
=Sum({<master_date={'>=$(=MonthStart(Max(master_date), -12))<=$(=MonthEnd(Max(master_date)))'}>}
MasterCalendar:
TempCalendar:
LOAD
$(vDateMin) + RowNo() - 1 AS DateNumber,
Date($(vDateMin) + RowNo() - 1) AS TempDate
AUTOGENERATE 1
WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);
MasterCalendar: this uses master_date to connect items together. This an fiscal calendar are hard to put together with rolling avg
LOAD
TempDate AS master_date,
Day(TempDate) AS CalendarDay,
WeekDay(TempDate) AS CalendarWeekDay,
Week(TempDate) AS CalendarWeek,
Month(TempDate) AS CalendarMonth,
Year(TempDate) AS CalendarYear,
'Q' & Ceil(Month(TempDate)/3) AS CalendarQuarter,
WeekDay(TempDate) & '-' & Year(TempDate) AS CalendarWeekAndYear,
Month(TempDate) & '-' & Year(TempDate) AS CalendarMonthAndYear,
If(Num(TempDate) >= $(vYearStart) AND Num(TempDate) < $(vMonthNow), -1, 0) AS YTD,
If(Num(TempDate) >= $(vYearStartLY) AND Num(TempDate) < $(vMonthNowLY), -1, 0) AS LY_YTD,
Year2Date(TempDate) * -1 AS YTD_Flag,
Year2Date(TempDate,-1, 1, $(vToday))*-1 AS LY_YTD_Flag
RESIDENT TempCalendar ORDER BY TempDate ASC;
DROP TABLE TempCalendar;
FiscalCalendar: This defines our fiscal year
FiscalCalendar:
LOAD date(date#(20011101,'YYYYMMDD')+recno(),'MM/DD/YY') AS "master_date"
AUTOGENERATE today()-date#(20011101,'YYYYMMDD');
LEFT JOIN (FiscalCalendar)
LOAD
"master_date",
date(monthstart(master_date),'MMM YY') AS "MonthFisical",
date(monthstart(master_date),'MMM') AS "MonthFisical_MonthTitle",
date(yearstart(master_date,1,11),'YYYY') AS "YearFiscal",
month(master_date)-month(num(today(1))) AS FiscalMonthsElapsed,
YearToDate(master_date, 0,11)*-1 AS YTD_FLAG_Fiscal,
YearToDate(master_date,-1,11)*-1 AS LY_YTD_FLAG_Fiscal
RESIDENT FiscalCalendar;
To see screenshots:
http://community.qlikview.com/message/219912#219912
Thank you for taking the time to look at this issue.
The solution is not in the calendar : you have to create a pivot table between your calendar and the fact table.
In this pivot table you have 2 type : DIRECT and CROSSING.
For type DIRECT, a row in fact table is linked to the date in calendar
For type CROSSING, a row in fact table is linked to all the dates of the 12 future months in calendar.
So in Qlikview, you use the type DIRECT all the time, except when you want to present for each month the total of the past 12 months. In this case you use CROSSING because all rows are linked to the dates of the 12 future months, so it means (reversed point of view) that a month is linked to all data of the past 12 months.
Examples:
xlsx
QVW