In IBM Cognos Report Studio
I have a data structure like so, plain dump of the customer details:
Account|Type|Value
123-123| 19 |2000
123-123| 20 |2000
123-123| 21 |3000
If I remove the Type from my report I get:
Account|Value
123-123|2000
123-123|3000
It seems to have treated the two rows with an amount '2000' as some kind of duplicated amount and removed it from my report.
My assumption was that Cognos will aggregate the data automatically?
Account|Value
123-123|8000
I am lost on what it is doing. Any pointers? If it is not grouping it, I would at least expect 3 rows still
Account|Value
123-123|2000
123-123|2000
123-123|3000
In any case I would like to end up with 1 line. The behaviour I'm getting is something I can't figure out. Thanks for any help.
Gemmo
The 'Auto-group & Summarize' feature is the default on new queries. This will find all unique combinations of attributes and roll up all measures to these unique combinations.
There are three ways to disable auto-group & summarize behavior:
Explicitly turn it off at the query level
Include a grain-level unique column, e.g. a key, in the query
Not include any measures in the query
My guess is that your problem is #3. The [Value] column in your example has to have its 'Aggregate Function' set to an aggregate function or 'Automatic' for the auto-group behavior to work. It's possible that column's 'Aggregate Function' property is set to 'None'. This is the standard setting for an attribute value and would prevent the roll up from occurring.
Related
I'm using sqlite-utils to load a csv into sqlite which will later be served via Datasette. I have two columns, likes and dislikes. I would like to have a third column, quality-score, by adding likes and dislikes together then dividing likes by the total.
The sqlite-utils convert function should be my best bet, but all I see in the documentation is how to select a single column for conversion.
sqlite-utils convert content.db articles headline 'value.upper()'
From the example given, it looks like convert is followed by the db filename, the table name, then the col you want to operate on. Is it possible to simply add another col name or is there a flag for selecting more than one column to operate on? I would be really surprised if this wasn't possible, I just can't find any documentation to support it.
This isn't a perfect answer as it doesn't resolve whether sqlite-utils supports multiple column selection for transforms, but this is how I solved this particular problem.
Since my quality_score column would just be basic math, I was able to make use of sqlite's Generated Columns. I created a file called quality_score.sql that contained:
ALTER TABLE testtable
ADD COLUMN quality_score GENERATED ALWAYS AS (likes /(likes + dislikes));
and then implemented it by:
$ sqlite3 mydb.db < quality_score.sql
You do need to make sure you are using a compatible version of sqlite, as this only works with version 3.31 or later.
Another consideration is to make sure you are performing math on integers or floats and not text.
Also attempted to create the table with the virtual generated column first then fill it with my data later, but that didn't work in my case - it threw an error that said the number of items provided didn't match the number of columns available. So I just stuck with the ALTER operation after the fact.
I’m looking for a simple expression that puts a ‘1’ in column E if ‘SomeContent’ is contained in column D. I’m doing this in Azure ML Workbench through their Add Column (script) function. Here’s some examples they give.
row.ColumnA + row.ColumnB is the same as row["ColumnA"] + row["ColumnB"]
1 if row.ColumnA < 4 else 2
datetime.datetime.now()
float(row.ColumnA) / float(row.ColumnB - 1)
'Bad' if pd.isnull(row.ColumnA) else 'Good'
Any ideas on a 1 line script I could use for this? Thanks
Without really knowing what you want to look for in column 'D', I still think you can find all the information you need in the examples they give.
The script is being wrapped by a function that collects the value you calculate/provide and puts it in the new column. This assignment happens for each row individually. The value could be a static value, an arbitrary calculation, or it could be dependent on the values in the other columns for the specific row.
In the "Hint" section, you can see two different ways of obtaining the values from the other rows:
The current row is referenced using 'row' and then a column qualifier, for example row.colname or row['colname'].
In your case, you obtain the value for column 'D' either by row.D or row['D']
After that, all you need to do is come up with the specific logic for ensuring if 'SomeContent' is contained in column 'D' for that specific row. In your case, the '1 line script' would look something like this:
1 if [logic ensuring 'SomeContent' is contained in row.D] else 0
If you need help with the logic, you need to provide more specific examples.
You can read more in the Azure Machine Learning Documentation:
Sample of custom column transforms (Python)
Data Preparations Python extensions
Hope this helps
I am using PHPExcel_v1_8, I have implemented formula to some cells like following.
$objPHPExcel->getActiveSheet()->SetCellValue('G4','=SUBTOTAL(2,B6:B'.$row.')');
$objPHPExcel->getActiveSheet()->SetCellValue('H4','=ROUND(SUBTOTAL(9,Q6:Q'.$row.'),2)');
I also tried like
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6,4,'=SUBTOTAL(2,B6:B'.$row.')');
Here $row means total number of rows.
But when I filter any column then it append/override value of formula applied cell. Please see following filtered total row.
I want only latest value should in filtered total row means want to replace existing value. Right now, I am getting correct value but why it is overrided? Any suggestions what can be the solution?
You've actually discovered a genuine bug here.
I wasn't aware when I implemented the SUBTOTAL logic in PHPExcel that it only worked with visible rows, and ignored hidden rows. Can you please raise an issue on the github repo
However, reading through the MS Excel docs for SUBTOTAL, a function of 2 or 9 will return the result for all rows in the range (hidden or otherwise) while 102 or 109 will return the result only for visible rows
I could find no relevant answers in either StackOverflow or google. Perhaps one of you has the answer. This is a continuation from a previous question...
In Business Objects Webi, I have two variables. One dimension, one measure. My goal is to create a simple pie chart.
Here's the dimension variable titled "EWFMCodeSelect":
`=If([Code]InList("BRK1"; "BRK2"; "BRK3" )) Then"BREAK"
ElseIf([Code]InList("TEAM"; "MTG"; "MTNG"; "PROJ"; "TRNG";"WCGB")) Then "DISC"
ElseIf([Code]InList("LUNCH")) Then "LUNCH"
ElseIf([Code]InList("LATE";"NOSHOW";"UNPAID";"UPVAC")) Then "MISS"
ElseIf([Code]InList("COACH";"VTO")) Then "NEUTR"
ElseIf([Code]InList("VAC";"LOA";"SICKUP";"SICKPL")) Then "NODISC"
ElseIf([Code]InList("PREP")) Then "OTHER"
ElseIf([Code]InList("OVER")) Then "OVER"
Else("SHIFT")`
This is the measure variable titled EWFMPieChart(%):
=[TimeDiff (ToInt)]
/ NoFilter(( Sum([TimeDiff (ToInt)]
ForAll([EWFMCodeSelect])
Where ([EWFMCodeSelect] = "SHIFT")))ForEach())
The previous advice I received was to filter the value "SHIFT" from the report block. I thought this would be a simple affair but it's proving more difficult than anticipated. I tried creating a Report Block filter in the Analysis tab "EWFMCodeSelect Not Equal To SHIFT"
"EWFMCodeSelect Not In List > SHIFT"
but only ended up with a single row, the dimension field empty, the measure field showing #MULTIVALUE. I tried a variety of other combinations but all had the same effect.
I tried a Column filter:
=[EWFMCodeSelect] Where ([EWFMCodeSelect] <> "SHIFT")
but ended up with a single row, the dimension field showing: "BREAKDISCLUNCH..." as the value and the measure, again, showing #MULTIVALUE.
I'm missing some important clue here. Can anyone educate me either why this approach is incorrect and maybe supply me with a direction to achieve my goal?
Thanks,
mfc
I don't have the correct answer but I did solve the problem by cleaning up all of the TEST variables, deleting all unused and unnecessary errata that collected up to this point and re-running the report as a scheduled item. I also cleared the browser cache (never bad advice).
After re-opening the report, I was able to filter the report block without issue.
I guess the answer is "When in doubt and receiving undocumented results, clean up your work-space and try again".
I have been struggling to get aggregation tables to work. Here is what my fact table looks like:
employment_date_id
dimension1_id
dimension2_id
dimension3_id
dimension4
dimension5
measure1
measure2
measure3
I'm collapsing the employment_date_id from year, quarter, and month to include just the year, but every other column is included. This is what my aggregation table looks like:
yearquartermonth_year
dimension1_id
dimension2_id
dimension3_id
dimension4
dimension5
measure1
measure2
measure3
fact_count
I'm only collapsing the year portion of the date. The remaining fields are left as is. Here is my configuration:
<AggFactCount column="FACT_COUNT"/>
<AggForeignKey factColumn="dimension1_id" aggColumn="dimension1_id"/>
<AggForeignKey factColumn="dimension2_id" aggColumn="dimension2_id"/>
<AggForeignKey factColumn="dimension3_id" aggColumn="dimension3_id"/>
<AggMeasure name="[Measures].[measure1]" column="measure1"/>
<AggMeasure name="[Measures].[measure2]" column="measure2"/>
<AggMeasure name="[Measures].[measure3]" column="measure3"/>
<AggLevel name="[dimension4].[dimension4]" column="dimension4"/>
<AggLevel name="[dimension5].[dimension5]" column="dimension5"/>
<AggLevel name="[EmploymentDate.yearQuarterMonth].[Year]" column="yearquartermonth_year"/>
I'm for the most part copying the 2nd example of aggregation tables from the documentation. Most of my columns are not collapsed into the table and are foreign keys to the dimension tables.
My query I'm trying to execute is something like:
select {[Measures].[measure1]} on COLUMNS, {[EmploymentDate.yearQuarterMonth].[Year]} on ROWS from Cube1
The problem is that when I debug it and turn on the logging I see bit keys that look like this:
AggStar:agg_year_employment
bk=0x00000000000000000000000000000000000000000000000111111111101111100000000000000000000000000000000000000000000000000000000000000000
fbk=0x00000000000000000000000000000000000000000000000000000001101111100000000000000000000000000000000000000000000000000000000000000000
mbk=0x00000000000000000000000000000000000000000000000111111110000000000000000000000000000000000000000000000000000000000000000000000000
And my query's bit pattern is:
Foreign columns bit key=0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
Measure bit key= 0x00000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000
And so my aggregation table is skipped. However, these are the exact columns that are folded into the table. But the bit positions are off between the query's and the aggregation table's. The other thing I find strange is that a portion of the columns is collapsed into the table, but all AggForeignKeys aren't included as bits so if I make a query with those columns this aggregation table will get skipped? That's counter to what I had planned. My plan was as long as you are making a query on year boundaries use this aggregation table.
I don't understand why this isn't working and why it fails to build the bit keys properly. I've tried debugging mondrian code, but figuring out which column maps to which position in the bit keys is not obvious. I feel like this shouldn't be this hard, but everything out there doesn't really explain this very well. And this aggregation table architecture is really to break.
What am I doing wrong? And why doesn't my solution work?
Update Here is my mondrian.properties file:
mondrian.jdbcDrivers=com.mysql.jdbc.Driver,oracle.jdbc.driver.OracleDriver
mondrian.rolap.generate.formatted.sql=true
mondrian.rolap.localePropFile=locale.properties
mondrian.rolap.aggregates.Use=true
mondrian.rolap.aggregates.Read=true
mondrian.trace.level=2
mondrian.drillthrough.enable=true
Might be the case mondrian.rolap.aggregates.Read is set to true and mondrian.rolap.aggregates.Use is set to false.
Please set mondrian.rolap.aggregates.Use=true and check.
Reference: http://mondrian.pentaho.com/documentation/configuration.php
If this is not the case, please attach all the properties related to aggregate tables and the complete cube definition XML.