Calculating % of Grand Total in Pivot Tables - pivot-table

I have a pivot table in Excel.
My dataset includes workforce numbers for the 32 states in the country, which are grouped in six different regions. This data set is divided into quarters since 2015 to date.
I need this table to show both the % of total workforce at a national level, and at a regional level.
I have tried using calculate, sum, allselected, but then if I use an slicer and show just one region, I end up with the % of workforce within that region and not at a national level.
I am a beginner in DAX and using Power Pivot, how can I calculate the total workforce at a national level for a given period so that it doesn't change if I change the region?
Please help!

Let's say you have a measure called "Total Workforce" (whatever it is - you haven't provided any information about its meaning).
To calculate total workforce at a national level, you need to create another measure:
National Workforce = CALCULATE( [Total Workforce], ALL(Table[Region]))
where Table is your table name, and Region is the name of the field containing regions. Function ALL in DAX removes all filters from a column, a list of columns, or an entire table.
Then, to calculate the ratio:
Workforce % of National = DIVIDE( [Total Workforce], [National Workforce])
Please note: it's very hard to answer questions like that without seeing your data, data model, formulas and the description of the desired outcome. It'd be great if you could provide this information.

Related

Google Data Studio convert metric to dimension not working

I have imported my GA4 data into Google Data Studio and am trying to see how many giftcards have been sold by their value.
The item revenue metric in GA4 is equal to the giftcard value (i.e. revenue = $200 therefore $200 giftcard was sold).
I want to breakdown sales by giftcard value like so:
Giftcard (revenue)
Count
$200
4
$250
3
$300
6
To do this, I need to set a copy of item revenue as a dimension rather than a metric.
In Google Data Studio, I can create a calculated field with the following formula that should convert the item revenue into text:
CAST(Item Revenue AS TEXT)
The problem I'm having is that while the formula sets the field type as text, it is still regarded by GDS as a metric and can't be used as a dimension.
Even when I try to add text, GDS still recognises the field as a number:
CONCAT(CAST(Item Revenue AS TEXT), " giftcard")
To use a metric as a dimension you can make a combination of data. When defining the graphic element (table, for example) and the respective data source, just create a data combination, but do not combine the data with any other source and just define the combination with the initial data itself. So you will have the same data structure only through a combined structure.
When making a combination of data, data studio recognizes all calculated fields (metrics) as dimensions. Thus, it is possible to make the conversion.

Is it possible to write a "matchmaking" query in Access 2007?

I am trying to create a database that will essentially act as a matchmaking service. I have two tables with the same categories, Clients and Opportunities.
The idea is to enter buy-side Clients as we acquire them, filling out the applicable descriptive fields (EBITDA, Gross Revenue, etc).
Then, when a possible Opportunity comes along, I enter that info in its respective table (with EBITDA, Gross Revenue, etc).
The idea is then to run a query that will essentially "match" records from Clients with records from Opportunities, in a prioritized order, i.e. the items with most matching fields rank at the top.
So I've created the tables (Clients and Opportunities), a third table Values that contains the possible choices for several of the fields, and forms for entering the information into Opportunities and Clients.
I've entered a test record in both Opportunities and Clients tables with several matching fields. But my query isn't returning any hits. Per some advice I received, I tried to add in some SQL code to address a possible NULL issue, but Access won't accept the code. Can this query be written? Are the results I'm looking for possible?
My query, designed using the Wizard, looks like this and returns no hits, despite the sample records in each table having matching entries:
SELECT Clients.*, Opportunities.*
FROM Clients INNER JOIN Opportunities
ON (Clients.[NAICS Sector Codes]=Opportunities.[NAICS Sector Codes])
AND (Clients.[Business Model]=Opportunities.[Business Model])
AND (Clients.[Gross Revenue]=Opportunities.[Gross Revenue])
AND (Clients.EBITDA=Opportunities.EBITDA)
AND (Clients.[EBITDA Margin (%)]=Opportunities.[EBITDA Margin (%)])
AND (Clients.[Growth-Timeframe in Years]=Opportunities.[Growth-Timeframe in Years])
AND (Clients.[Growth-Revenue]=Opportunities.[Growth-Revenue])
AND (Clients.[Growth-EBITDA (%)]=Opportunities.[Growth-EBITDA (%)])
AND (Clients.[Geographical Operational Location Preference]=Opportunities.[Geographical Operational Location Preference])
AND (Clients.[Debt Load]=Opportunities.[Debt Load])
AND (Clients.[Primary Area of Sales Concentration (Geographic)]=Opportunities.[Primary Area of Sales Concentration (Geographic)])
AND (Clients.[% of total revenue from ≤ top 3 customers]=Opportunities.[% of total revenue from ≤ top 3 customers])
AND (Clients.[% of total revenue from ≤ top 10 customers]=Opportunities.[% of total revenue from ≤ top 10 customers])
AND (Clients.[% of total revenue from ≤ top 20 customers]=Opportunities.[% of total revenue from ≤ top 20 customers])
AND (Clients.[Current Management Post-Transaction Plan]=Opportunities.[Current Management Post-Transaction Plan])
AND (Clients.[Preferred Deal Structure]=Opportunities.[Preferred Deal Structure]) AND (Clients.NAPCS=Opportunities.NAPCS)
AND (Clients.Notes=Opportunities.Notes)
AND (Clients.[ZLD Sector Notes]=Opportunities.[ZLD Sector Notes]);

How to show subtotal and total of groups in ssrs

I am making an SSRS report in following format:
DIVISION
SECTOR
DEPARTMENT
Division contain Sector and Sector contain Department so resulting report becomes something like following. A figure is being shown against each Department and I want to show SUBTOTAL of each Sector right against Sector column (by adding all Department coming under it) and then show TOTAL of Division (by adding all Department or all Sector) at the end. How do I show these totals?
Division1
Sector1 SUBTOTAL HERE (for e.g. 19,000)
Department1 10,000
Department2 9,000
Sector2 SUBTOTAL HERE (for e.g. 8,000)
Department3 8,000
Sector3 SUBTOTAL HERE (for e.g. 13,000)
Department4 10,000
Department5 1,000
Department6 2,000
TOTAL HERE (for e.g. 40,000)
Division2
Sector4 SUBTOTAL HERE (for e.g. 3,500)
Department7 3,500
TOTAL HERE (for e.g. 3,500)
My report is displaying all divisions, sectors and departments with figures like above (I am using groups ) but how do I display SUBTOTAL and TOTAL?
for this report I will assume you have three groups in your Row Groups Pane (Row groups will be there either you use a Matrix or Tablix).
DIVISION (DIVISION Group)
SECTOR (SECTION Group)
DEPARTMENT (Details Group)
Adding totals and sub totals are probably the simplest task in SSRS. See below goto your Row groups pane and add Totals to all the groups you want to, Which will appear as Totals and Sub Totals in your report.

How to add an non aggregated column in a fact table?

I'm working on a SSAS cube to allow user to analyze some sales.
So, I created a fact table to record all sales and few dimensions to browse inside data (category / location & store, etc...).
This is a example of the fact table output (from SQL Server Management Studio) :
When I browse my cube, I can review all sales including date, quantity, etc.
However, when I add some fields like the "unit price" or the "unit cost", it returns me a strange result probably due to an aggregate behavior.
It seems it return the sum of all matching rows (aggregateFunction property).
How to simply display the unit price of a sale without apply any calculation to the unit price column. The None value for the AttributeFunction display BLANK/NULL.
If your unitCost and unitPrice are the same for each product (I mean unitCost can be only 77.6 for product_id = 2), you can just use average (or even emulate average by SUM/COUNT) - but only for product dimension on axis!
Another dimensions will show real average values.
Maybe it's better to use this 'static' fields like attribute properties in 'Product' dimension? But you still need to add some logic to choose one value for several (or all) product members selected.

How to create the value I want by combining two pivot tables

I have combined two datas which are price 2013 and volume 2013 to create one pivot table. But how can I find revenue (Volume multiply price) by using pivot table? Please help. Thanks. My column field there included Price from data 1 and volume from data 2.
Switch one of the fields to Σ Values (Volume would seem to be the more sensible) and add a Calculated Field (PivotTable Tools, Options > Tools - Formulas) say Named: Revenue and with Formula: Volume*Price.
However depending upon your version of Excel and your data, you may receive incorrect results (eg in the GT row for revenue).

Resources