GROUP BY over data in PowerPivot - sql

In my PowerPivot I have a master data table which comes via an extract from system x. Now I want to be able to "GROUP BY" over a certain column from the same data. What would be the best approach here? There are more than 600.000 lines involved.
I have already tried following DAX query but it won't work:
SUMMARIZE('SAP extract', [cost element], sum('SAP extract'[val]))
Returns:
Query(1,, 47) Function SUMMARIZE expects a column name as argument number 3.

Kris,
I would suggest creating a new measure -- guessing from you question, that would probably be a simple SUM (see documentation here), something like:
=SUM(Sales[Amt])
This should be then automatically added to your currently active powerpivot table.
If you then want to group the data by anything, simply drag the dimension into the rows section and you should be able to see the aggregated sums sliced by the dimension you chose.
Hope this helps.

Related

Trying to count records in SSRS from different data sets

I have an SSRS report that combines 5 reports into one. Each report is populated from a different stored procedure. The first page is a summary that is to provide a record count from each report. I've created fields in the stored procedure that provides the counts for each individual report: phycount and nonphyscount. I'm trying to create a table similar to this:
Active comes from one data set, Initial comes from another, Recert comes from another, etc.
I've been playing around with the Lookup and LookupSet but I'm just getting errors, plus I'm not sure if that's even the right direction.
Does anyone know how to do this?
Lookup and Lookupset are more for getting specific values out of a dataset. Very useful but not necessary for what you're trying to accomplish.
You can use aggregate functions SUM and COUNT to accomplish what you want to do. The cool thing about these functions is you can actually embed IIF statements inside of them.
I'm not sure exactly how your datasets look and are named but it would be something like this...
SUM(IIF(Fields!Type.Value = "PhyCount", 1, 0), "Active")
The sum function goes through every row of your dataset and sums the values you pass to it. The iif statement checks to see if the type field in the dataset is "PhyCount". If so, it returns 1, if not, 0. Since this will happen for every row, your SUM function will return a count of each row with status active.
edit: "Active" after the iif statement specifies the name of the dataset.
EDIT AGAIN: This solution apparently does not work in SSRS 2008.

How to add a field to a report that has groups

I need to add a field to a SSRS report. I tried modifying the dataset (query) but the results prouduced insane results, with zipcodes showing up in the name fields and names showing up in a datetime field. I suspect it is because of the groups but I don't understand how they work. The Dataset is created by 4 selects. The first 3 insert into temp tables and the fourth pulls from it. I suspect that I will have to re-write the query but it would be nice if I could use it as is with modifications. Either way I need to understand the groups.
I read
Data Region Cells, Data Region and Understanding Groups. Aside from the fact that they use terms specific to SSRS without defining them they are so undetailed I doubt many people who do not already understand SSRS can get anything out of them.
I did not write this report but I must modify it. I understand SQL well. Not so much with SSRS.
Can anyone explain how to find out what the Row Groups mean? Mine look like this:
Here is the tablix

Summing different parts of a column in SQL

I have a database extract in excel and want to create a custom value in Tablue using their create calculation, which I believe is SQL based.
Basically I have a large number of feeds which all show up different amounts in a column. For example:
feed 1
feed 1
feed 2
feed 3
feed 4
feed 4
feed 4
And I want to have a sum for feed 1, feed 2, and feed 4. But in my actual DB there's about 100 feeds all with different number of appearances. I'm having troubles finding a good way to do this. If there even is one. Any help or direction would be appreciated!
I'm assuming that your list is a single column and you need a count of the number of occurrences of each feed. For the sake of example, since a column or table names were not supplied, let's call them colname and tablename.
select colname, count(*) as Ct from tablename group by colname
It would be easier to give an exact answer if you posted a small simplified subset of your spreadsheet. But assuming you have a column called "feed_name" which takes on values like "feed 1", "feed 2" etc depending on the row. Then the feed_name column should be a discrete dimension in Tableau.
Then just put the feed_name pill on a shelf, say the row shelf. And put the "Number of Records" field on another shelf, say the column shelf.
You don't need to write SQL to do this (or most tasks) in Tableau. It helps to understand SQL concepts and its very helpful to drop down to the SQL level when needed to solve tricky issues. But for most situations, you can just interactively explore the data by moving fields around and writing some simple calculations -- and let Tableau take care of generating the SQL necessary to retrieve the data needed to build the visualization you requested.
Tableau supports SQL and some NO-SQL data sources, along with some cubes too. It does that quite well and in multiple ways. You just can work more quickly and efficiently by using Tableau's visual based manipulations in most cases, and then drop to the lower level detail when needed. It just takes getting used to how Tableau operates.

Pentaho Report Designer: How to create a chart based on an OLAP cube?

Using Pentaho Report Designer, I can successfully display my OLAP cube's data as a table.
But when I want to display the same data as a chart, it always fail saying "CHART.USER_NO_DATA_AVAILABLE".
Actually, I don't really know what I should enter for category-column and value-columns. I tried:
category-column = [Area].[prefecture]
value-columns = [[Product].[Product.Product].[All Products].[productA]]
And any other variation I could think of, but no success. Any idea? Thanks!
My OLAP cube is a Pentaho Analysis: sales count for each product and prefecture.
Just use:
[Product].[Product.Product].[All Products].[productA]
You only need the extra square brackets around the entire fieldname if it's a formula.
Or pick the field from the dropdown.. then you know you have the right one!
If you're doing a timeseries xy, note you have to repeat the category column value as many times as the value column.
also make sure you have a series name too.

How to specify an order for the columns in a matrix?

I'm working on a SQL Reporting Services report (in VS.Net 2005) which displays a count of different data in a matrix. The columns have a count on the amount of customers in a certain set. So I have several columns like these: "1 employer", "2-9 employers", "10-19 employers" and so on.
The problem I have is that SQL Reporting Services sorts the columns in the matrix alphabetically. So I end up having the "10-19" column after the "1 employer" column but before the "2-9".
Is there any way to fix this?
Or maybe a trick to change the labels of the columns to that they sort right?
Thanks.
This can also be done by adding a new column to the query for the sort order. Then right click the column group from the matrix and select group properties. On the left hand side select sorting. From here you can specify another column to sort by instead of the column header. No custom formula needed.
We do a lot of SSRS Reports and this was always an issue with mdx. Here is one way we do it:
Set Sorting in the Grouping and Sorting Properties to sort by this expression:
=iif(Fields!DataSetField.Value = "ColumnName", "zzz", Fields!DataSetField.Value)
Where "zzz" could be a number or whatever you need it to be to help the sort and then select Direction as either Ascending or Descending base on this expression.
This may be a bit convoluted, but we had a similar problem and no means to change the SQL.
What we did was create a calculated field in the dataset that returns a number for each column and sorted the group on that number.
I had a similar problem but did not find a solution using a matrix in time - so I used a table - and put the needed logic of the matrix in my SQL-statements.
It's not the best thing to do but it works - it's fast enough and it don't takes that long to write.
I went into MATRIX --> PROPERTIES --> GROUPS.
Then, I "moved" the GROUP I wanted it to sort by UP in the list.
I went to PREVIEW, and it worked perfectly.
It even kept my column order the same.
Go to Edit Group - Sorting - Change the direction to descending for the expression.
For distinct numeric order of a Tablix use following line of code in expression.
=RunningValue(CountDistinct("YourTableName"),Count,"YourTableName")
Simply Go to tablix/Matrix Column Group and Right Click on the Group Properties then go Sorting and Delete the auto added record from Sorting.. Now your sorting will based on the Data you have added in Data set.