MDX and PieChart - mdx

I'm trying to display a PieChart on using Community Dashboard Framework with this simple query:
with member [Measures].[ContaComp] as
'Iif(IsEmpty([Measures].[COUNT_COMPONENTI]), 0, [Measures].[COUNT_COMPONENTI])'
select NON EMPTY {[Measures].[ContaComp]} ON COLUMNS,
{DIM_SESSO.All, DIM_SESSO.M, DIM_SESSO.F} on 1
from anagrafe
WHERE DIM_STATO_RECORD.A
which returns this dataset:
Axis #0:
{[DIM_STATO_RECORD].[A]}
Axis #1:
{[Measures].[ContaComp]}
Axis #2:
{[DIM_SESSO].[ALL]}
{[DIM_SESSO].[M]}
{[DIM_SESSO].[F]}
Row #0: 2.145
Row #1: 1.011
Row #2: 1.134
What I'm wrong? Nothing appears on the chart componet.... even if about me this dataset is ok to display in a pie chart, isn't it?
What is the difference respect to the following mdx query which works?
select NON EMPTY {[Measures].[count]} ON COLUMNS,
NON EMPTY {[DIM_LOCALITA.LOCALITA].[X].Children} ON ROWS
from [Pratiche]
where ([DIM_STATO_RECORD].[A], [DIM_TIPO_PRATICA].[RS])
and rerturns the following dataset, which is similar to the previous one?
Axis #0:
{[DIM_STATO_RECORD].[A], [DIM_TIPO_PRATICA].[RSA13]}
Axis #1:
{[Measures].[COUNT_PRATICHE]}
Axis #2:
{[DIM_LOCALITA.LOCALITA].[X].[X1]}
{[DIM_LOCALITA.LOCALITA].[X].[X2]}
{[DIM_LOCALITA.LOCALITA].[X].[X3]}
{[DIM_LOCALITA.LOCALITA].[X].[X4]}
{[DIM_LOCALITA.LOCALITA].[X].[X5]}
{[DIM_LOCALITA.LOCALITA].[X].[X6]}
{[DIM_LOCALITA.LOCALITA].[X].[X7]}
{[DIM_LOCALITA.LOCALITA].[X].[X8]}
{[DIM_LOCALITA.LOCALITA].[X].[X9]}
{[DIM_LOCALITA.LOCALITA].[X].[X10]}
Row #0: 15
Row #1: 11
Row #2: 180
Row #3: 74
Row #4: 67
Row #5: 3.063
Row #6: 13
Row #7: 55
Row #8: 20
Row #9: 321

Related

How do you iterate through a data frame based on the value in a row

I have a data frame which I am trying to iterate through, however not based on time, but on an increase of 10 for example
Column A
Column B
12:05
1
13:05
6
14:05
11
15:05
16
so in this case it would return a new data frame with the rows with 1 and 11. How am I able to do this? The different methods that I have tried such as asfreq resample etc. don't seem to work. They say invalid frequency. The reason I think about this is that it is not time based. What is the function that allows me to do this that isn't time based but based on a numerical value such as 10 or 7. I don't want the every nth number, but every time the column value changes by 10 from the last selected value. ex 1 to 11 then if the next values were 12 15 17 21, it would be 21.
here is one way to do it
# do a remainder division, and choose rows where remainder is zero
# offset by the first value, to make calculation simpler
first_val = df.loc[0]['Column B']
df.loc[((df['Column B'] - first_val) % 10).eq(0)]
Column A Column B
0 12:05 1
2 14:05 11

Collapse pandas DataFrame based on daily column value

I have a pandas DataFrame with multiple measurements per day (for example hourly measurements, but that is not necessarily the case), but I want to keep only the hour for which a certain column is the daily minimum.
My one day in my data frame looks somewhat like this
DATE Value Distance
17 1979-1-2T00:00:00.0 15.5669870447436 34.87
18 1979-1-2T01:00:00.0 81.6306803714536 31.342
19 1979-1-2T02:00:00.0 83.1854759740486 33.264
20 1979-1-2T03:00:00.0 23.8659679630303 32.34
21 1979-1-2T04:00:00.0 63.2755504429306 31.973
22 1979-1-2T05:00:00.0 91.2129044773733 34.091
23 1979-1-2T06:00:00.0 76.493130052689 36.837
24 1979-1-2T07:00:00.0 63.5443183375785 34.383
25 1979-1-2T08:00:00.0 40.9255407683688 35.275
26 1979-1-2T09:00:00.0 54.5583051827551 32.152
27 1979-1-2T10:00:00.0 26.2690011881422 35.104
28 1979-1-2T11:00:00.0 71.3059740399097 37.28
29 1979-1-2T12:00:00.0 54.0111262724049 38.963
30 1979-1-2T13:00:00.0 91.3518048568241 36.696
31 1979-1-2T14:00:00.0 81.7651763485069 34.832
32 1979-1-2T15:00:00.0 90.5695814525067 35.473
33 1979-1-2T16:00:00.0 88.4550315358515 30.998
34 1979-1-2T17:00:00.0 41.6276969038137 32.353
35 1979-1-2T18:00:00.0 79.3818377264749 30.15
36 1979-1-2T19:00:00.0 79.1672568582629 37.07
37 1979-1-2T20:00:00.0 1.48337999844262 28.525
38 1979-1-2T21:00:00.0 87.9110385474789 38.323
39 1979-1-2T22:00:00.0 38.6646421460678 23.251
40 1979-1-2T23:00:00.0 88.4920153764757 31.236
I would like to keep all rows that have the minimum "distance" per day, so for the one day shown above, one would have only one row left (the one with index value 39). I know how to collapse the data frame so that I only have the Distance column left. I can do that - if I first set the DATE as index - with
df_short = df.groupby(df.index.floor('D'))["Distance"].min()
But I also want the Value column in my final result. How do I keep all columns?
It doesn't seem to work if I do
df_short = df.groupby(df.index.floor('D')).min(["Distance"])
This does keep all the columns in the final result, but it seems like the outcome is wrong, so I'm not sure what this does.
Maybe this is already posted somewhere, but I have trouble finding it.
You can use aggregate
df_short = df.groupby(df.index.floor('D')).agg({'Distance': min, 'Value': max})
If you want the kept Value column is the same with minimum of Distance column:
df_short = df.loc[df.groupby(df.index.floor('D'))['Distance'].idxmin(), :]
Make a datetime Index:
df.DATE = pd.to_datetime(df.DATE) # If not already datetime.
df.set_index('DATE', inplace=True)
Resample and find the min Distance's location:
df.loc[df.resample('D')['Distance'].idxmin()]
Output:
Value Distance
DATE
1979-01-02 22:00:00 38.664642 23.251

How number of MFCC coefficients depends on the length of the file

I have a voice data with length 1.85 seconds, then I extract its feature using MFCC (with libraby from James Lyson). It returns 184 x 13 features. I am using 10 milisecond frame step, 25 miliseconds frame size, and 13 coefficients from DCT. How can it return 184? I still can not understand because the last frame's length is not 25 miliseconds. Is there any formula which explain how can it return 184? Thank you in advance.
There is a picture that can explain you things, basically the last window takes more space than previous ones.
If you have 184 windows, the region you cover is 183 * 10 + 25 or approximately 1855 ms.

Complex Formulas within Excel Using VBA

I am working on vba code where I have data (for Slope Inclinometers) at various depths like so:
Depth A0 A180 Checksum B0 B180 Checksum
4.5 (-1256) 1258 2 (-394) 378 (-16)
4.5 (-1250) 1257 7 (-396) 376 (-20)
4.5 (-1257) 1257 0 (-400) 374 (-26)
Depth A0 A180 Checksum B0 B180 Checksum
5 (-1214) 1214 0 (-472) 459 (-13)
5 (-1215) 1212 -3 (-472) 455 (-17)
5 (-1216) 1211 -5 (-473) 455 (-18)
UNKNOWN AMOUNT OF DATA WILL BE PRESENT (depends how much the user transfers to this sheet)
Now I need to be able to calculate the A Axis Displacement, the B Axis Displacement, and the resultant which have formulas as followed:
A Axis Displacement = [((A0-A180)/2)-((A0*-A180*)/2))]*(constant/constant)
Where * is the initial readings which is always the first row of data at that specified depth.
B Axis Displacement = [((A0-A180)/2)-((A0*-A180*)/2))]*(constant/constant)
Where * is the initial readings which is always the first row of data at that specified depth.
Resultant = SQRT[(A Axis Displacement)^2 + (B Axis Displacement)^2]
I'm struggling to find examples of how I can implement this using vba as there will be various depths present (unknown amount) on the same sheet where the formula will need to start over at each new depth present.
Any helps/tips would be greatly appreciated!
how I can implement this using vba as there will be various depths present...
You still can do it purely with formulas and easy auto-fill, because the formula can find the the first occurrence of the current depth and perform all the necessary calculations, leaving blank at header rows or blank rows. For instance, you can enter these formulas at row 2 and fill down all the rows.
H2 (A Axis Displacement):
=IF(ISNUMBER($A2),0.5*(B2-C2-VLOOKUP($A2,$A:$F,2,0)+VLOOKUP($A2,$A:$F,3,0)), "")
I2 (B Axis Displacement):
=IF(ISNUMBER($A2),0.5*(E2-F2-VLOOKUP($A2,$A:$F,5,0)+VLOOKUP($A2,$A:$F,6,0)), "")
J2 (Resultant):
=IF(ISNUMBER($A2),SQRT(SUMSQ(H2,I2)),"")
p.s. in the displacements formulas I omitted the (constant/constant) factor as it is irrelevant to the answer, you can easily multiply the 0.5 factor by anything you need.

SQL Server Reporting services chart report

I currently have a dataset with the columns API50, Counter Value and DBName. The values for example are something as below.
API50 CounterValue DBName
34.5 1 Test1
44.5 25 Test1
34.5 42 Test1
54.5 67 Test1
34.5 76 Test1
94.5 88 Test1
14.5 99 Test1
I have created a chart report and selected my X axis as CounterValue my Y axis as API50.
The report is plotted correctly and my Y axis goes only upto 99.
Is there anyway I can have my X axis as 50 point increments till 600 (e.g., 0, 50, 100, 150...and so on till 600) and plot the counter value?
Any help is greatly appreciated.
Creating a basic chart with your sample data:
Gets the same result you have described, i.e. the X Axis just goes up to the maximum CounterValue value or so:
You need to update the X Axis properties:
Here I've updated:
List item
Maximum
Interval
Interval Type
I've also checked the Scalar Axis value - this is most important otherwise the above values won't work properly.
Now you can see the change in the designer:
And the end result has your axis requirements: