How to properly display Pie Chart in MS Access Form? - sql

Given this Query
TRANSFORM Count(books.ID) AS CountOfID
SELECT books.Category
FROM books
WHERE (((books.Category)='Fantasy'))
GROUP BY books.Category
PIVOT (Switch(books.status=1,'Available',books.status=2,'Reserved',books.status=3,'Unavailable'));
that gives this result:
Category Total Available Unavailable
Fantasy 116 46 70
I am trying to display it on a Pie Chart which, somehow shows the portion per status together with its value, look like this:
but instead, I am getting this result:
I don't know where the East, West, and North are coming from. Another thing I observed is in the Row Source property why it becomes like this:
SELECT [Unavailable],Sum([Available]) AS [SumOfAvailable] FROM [qryGetFantasy] GROUP BY [Unavailable];
I am using Office 2013.
Any help is much appreciated.

Related

Pivot Table In BigQuery Using Standard SQL

I have a set of data (referenced the attached Excel sheet) that is unpivoted, which I am trying to pivot and convert the rows to columns.
In this case, the yellow headers are duplicated data. The green headers are what I want to convert from rows to columns, which will remove the duplication and thus pivot the data.
The top of the Excel sheet is what I have currently, the bottom is what I am wanting to get to.
I am using BigQuery standard SQL.
Any help is appreciated.
Excel Screenshot
Here is a short sample of what I have.
catalog_number
manufacturer
region
region_price
region_catalog_number
123
nike
north
10
123-n
123
nike
south
8
123-s
Here is a sample of what I want.
catalog_number
manufacturer
region_north
region_north_price
region_north_catalog_number
region_south
region_south_price
region_south_catalog_number
123
nike
north
10
123-n
south
8
123-s
Consider below simple approach
select *
from your_table
pivot (
any_value(region) region,
any_value(region_price) region_price,
any_value(region_catalog_number) region_catalog_number
for region in ('north', 'south')
)
if applied to sample data in your question - output is

With MDX is there a generic way to calculate the ratio of cells with regards to the selected members of a specific hierarchy?

I want to define a cube measure in a SSAS Analysis Services Cube (multidimensional model) that calculates ratios for the selection a user makes for a predefined hierarchy. The following example illustrates the desired behavior:
|-City----|---|
| Hamburg | 2 |
| Berlin | 1 |
| Munich | 3 |
This is my base table. What I want to achieve is a cube measure that calculates ratios based on a users' selection. E.g. when the user queries Hamburg (2) and Berlin (1) the measure should return the values 67% (for Hamburg) and 33% (for Berlin). However if Munich (3) is added to the same query, the return values would be 33% (Hamburg), 17% (Berlin) and 50% (Munich). The sum of the values should always equal to 100% no matter how many hierarchy members have been included into the MDX query.
So far I came up with different measures, but they all seem to suffer from the same problem that is it seems impossible to access the context of the whole MDX query from within a cell.
My first approach to this was the following measure:
[Measures].[Ratio] AS SUM([City].MEMBERS,[Measures].[Amount])/[Measures].[Amount]
This however sums up the amount of all cities regardless of the users selection and though always returns the ratio of a city with regards to the whole city hierarchy.
I also tried to restrict the members to the query context by adding the EXISTING keyword.
[Measures].[Ratio] AS SUM(EXISTING [City].MEMBERS,[Measures].[Amount])/[Measures].[Amount]
But this seems to restrict the context to the cell which means that I get 100% as a result for each cell (because EXISTING [City].MEMBERS is now restricted to a cell it only returns the city of the current cell).
I also googled to find out whether it is possible to add a column or row with totals but that also seems not possible within MDX.
The closest I got was with the following measure:
[Measures].[Ratio] AS SUM(Axis(1),[Measures].[Amount])/[Measures].[Amount]
Along with this MDX query
SELECT {[Measures].[Ratio]} ON 0, {[City].[Hamburg],[City].[Berlin]} ON 1 FROM [Cube]
it would yield the correct result. However, this requires the user to put the correct hierarchy for this specific measure onto a specific axis - very error prone, very unintuitive, I don't want to go this way.
Are there any other ideas or approaches that could help me to define this measure?
I would first define a set with the selected cities
[GeoSet] AS {[City].[Hamburg],[City].[Berlin]}
Then the Ratio
[Measures].[Ratio] AS [Measures].[Amount]/SUM([GeoSet],[Measures],[Amount])
To get the ratio of that city to the set of cities. Lastly
SELECT [Measures].[Ratio] ON COLUMNS,
[GeoSet] ON ROWS
FROM [Cube]
Whenever you select a list of cities, change the [GeoSet] to the list of cities, or other levels in the hierarchy, as long as you don't select 2 overlapping values ([City].[Hamburg] and [Region].[DE6], for example).

SSRS Lookup on single dataset

Hopefully you can help!
I have a single data source in my SSRS report. With this data source, I have populated a tablix. The tablix looks something like this:
SalesPerson ID Group Sales
Sarah 1 1 1234
Ross 2 1 555
Gemma 3 2 678
Jill 4 2 345
Jack 5 3 987
Peter 6 2 432
Henry 7 2 356
The report is set up to create a different page for each of the sales people. for example, on the first page of the report, only first record would be shown (the record that holds Sarah's information, the second page would show the record for Ross' information ,etc..)
The issues I face is this:
At the bottom of the report, I need to include a textbox that displays the group number that the specific employee belongs to (the employee who is currently being displayed on the page).
I think that I need to do some sort of lookup on the IDReportItem to return the group ID in order to do this, but have had no luck in my attempts.
I understand that this is a horrible way of doing things, but I am limited to using this single dataset for performing this task.
Any help you can provide will be greatly appreciated,
Thanks you!
Unfortunately there doesn't seem to be a way to do this in a single textbox, but you can do it with a second tablix that uses the same dataset.
Create your second tablix and position it at the bottom of the page, then set your grouping to be the same on both tablixes and use the second tablix to only display the group ID, plus whatever label you want.
Create a new row group for each tablix (grouping on group ID), then right click the group and browse to Group Properties -> Page Breaks and check the box that says "Between each instance of a group". Do this for both tablixes.
This is what grouping is designed for. Build your table, and set the page break attribute to true.
You can have multiple rows under your group. Since your group is a field, simply add it to the detail row.
Your grouping is obviously set up right to get the report paging correctly.
You could add a List to the report, set the grouping on that (with page break between groups)
Inside the list - Add a RECTANGLE. (this be important!)
Once you've added the rectangle, you can add another as many objects as you like. In your case I think that may be a matrix and a text box
eg
Then it just becomes as spacing issue (to get the page looking right)

Two header with own line item in one display

I got a request from user to develop a report that show the invoice detail in one display.
All I found was how to show two different tables in the same page.
Is there a way to show it in the same table but with two header?
It's something like this.
HD Billing Doc. Doc. Currency Sales Org Distr. Channel Billing Date
IT Item Billed qty Sales unit Net weight Net value
HD 900230006 USD JH01 01 05.01.2014
IT 10 60 KG 60 1000
IT 20 20 BAG 20 4000
HD 900230007 EUR JH01 01 05.01.2014
IT 10 22 KG 22 990
IT 20 67 BAG 67 456
IT 30 15 KG 15 897
You can use ALV functionality to do this.
You can use the ALV object model to apply tables in three different
ways:
as a simple, two-dimensional table ( CL_SALV_TABLE class)
as a hierarchically-sequential table
The following paragraphs relate to this table. as a tree structure ( CL_SALV_TREE class)
See program SALV_DEMO_TREE_SIMPLE or SALV_DEMO_HIERSEQ_SIMPLE in package SALV_OM_OBJECTS as an examples. The class documentation is also pretty good.
Alternatively you can try using function module REUSE_ALV_HIERSEQ_LIST_DISPLAY, but this is older functionality
Functionality This module outputs two internal tables as a formated
hierarchical-sequential list.
Principle:
Pass an internal table containing the set of header information to be output.
Pass an internal table containing the set of item information to be output.
Pass a structure containing the general list layout details
Pass a field catalog in the form of an internal table. The field catalog describes the fields to be output in the list.
See program BCALV_TEST_HIERSEQ_LIST in package SLIS as an example.

DAX for Grouping

I have following data set as data Model.
Country City AssetCount
USA Newyork 50
USA Washington 40
USA California 30
India Bangalore 100
India Delhi 50
India Bombay 30
I want to show one row showing sum of Assetcount at country level & city level on the same row.
There are two slicers for slicing City & Country as below:
USA Newyork
India Washington
California
Bangalore
Delhi
Bombay
So when I select country as India it should show sum of Asset-Count at country(India) level.
In the same way when I select City as Delhi it should show Asset-Count at City(Delhi) level.
India Delhi
180 50
Is it possible using PowerPivot using DAX?
Related content from their question on MSDN
Actually your solution is not working. I have created the hierarchy as Country-->City & kept that in Rows. So when I select a particular Country & City it showing like this:
Row Labels AssetCount
USA 40
Washington 40
Grand Total 40
But I want
USA Washington
120 40
or may be like
USA 120
Washington 40
I have tried some aggregate functions like below:
=SUMX(VALUES(Query[City]),CALCULATE(SUM(Query[AssetCount])))
=CALCULATE(SUM(Query[AssetCount]),SUMMARIZE('Query',Query[City]))
Here Query is table for Data Model & City can be replaced by Country.
but not working.
So showing such counts on same row is possible or not?
Sounds like you are just getting started with Power Pivot. You might browse through the links on this page for more help.
I took the data you provided and pasted it into Excel.
Selected the data and clicked Add to Data Model and checked the box for My Data Has Headers.
I made sure the AssetCount Column had a data type of whole number. Then clicked the Pivot Table button and created a pivot table on my existing spreadsheet.
I put AssetCount in the values and made sure it was set to Sum in the Field Value Settings.
I selected my pivot table and then went to the Analyze tab under PivotTable Tools and clicked the Insert Slicer button.
I selected both Country and City as slicers.
This gives your desired result.
If you want the two numbers in a row, that's pretty straightforward. Keep in mind, that all those slicers do is putting filters on the pivot table.
Therefore to get your city result, you could use either an implicit measure or explicit measure that simply sums up AssetCount.
For the country result, you'd wish to overload the city filter like this:
=calculate(SUM(Query[AssetCount]),ALL(Query[City]))
If you also need the country and city names there, it gets a bit tricky.