Selecting a measures value with slicers in PowerPivot - excel

I'm using PowerPivot in Excel 2010 to analyse some data. I have a situation where I have several boolean measures evaluating whether or not a condition is met. My Pivot table looks like this:
ROW LABEL VALUE CONDITION_MET
-----------------------------------
AAAA 10.5 TRUE
AAAB 9.5 FALSE
AAAC 11.29 TRUE
The measure to determine whether or not the criteria is met is non-trivial so I can't get users to select the right combination of groups in slicers to find the data.
Ideally I want a solution that allows me to have a slicer that looks like below:
SLICER
-----
TRUE
FALSE
This filters my pivot table accordingly to just the records that match.
Anyone got any ideas? I'm reading about disconnected slicers but not making much progress.

Disconnected slicers is one way to tackle this problem.
Lets say you create a 2 row table called 'TrueFalse' with a column called 'tf' and rows TRUE and FALSE.
You can then write a measure that counts the number of rows in that table that equal the value of the measure - if you then slice on the 'TrueFalse' table the option that you haven't selected will return BLANK() so will not be displayed.
The measure could look something like this:
=CALCULATE (
COUNTROWS ( truefalse ),
FILTER ( truefalse, truefalse[TF] = [Measure] )
)

Related

power BI or Excel - How to add a custom column based on columns in the pivot table

This is the sample of raw data. It shows the value that each of the property got on a scale of 1-10.
Pivot Table showing count of Value on scale for each property
I want to create a custom column in a pivot table in excel or a matrix in power Bi. This column should be based on the columns in the pivot table and not on the already existing columns in the table.
Eg. I have a table with column labels from 1 to 10 and a Total column. I created a pivot table to show the count of each of these columns. In the example here, Mountain has 162 values of 8, 197 values of 9 and 268 values of 10. My question is I want to create a new custom column which is the sum of just these three values divided by the total count. In this example , it is(162+197+268)/829 = 76%
I am not able to do it. Please help me out
In Power BI you're looking at measures something like this.
SurveyCount := CountRows(MyTable)
CountAllValues := CALCULATE(SurveyCount,ALL(MyTable[Value On A Scale (1-10)]))
Count8Plus := CALCULATE(SurveyCount,MyTable[Value On A Scale (1-10)] >= 8)
Percentage8Plus := DIVIDE(Count8Plus , CountAllValues )
The syntax might need a little tweak but these four should get you close to what you need.

How to use Or filters for getting data from OLAP cube pivot table in Excel

We are loading data from an SSAS model (cube) into an Excel pivot table. The data within the spreadsheet needs to be shown using 2 conditions in OR way, I mean, I have 2 fields coming from the database: Original amount and amendment amount, We need display the information coming from the SSAS cube when original amount <=10.000 OR amendment_amount<=10.000.
I tried to use the normal filters on Excel pivot tables, but it doesn't worked, because filters use AND implicitly to display information, I need OR.
I tried to use the normal filters on Excel pivot tables (value and label filters), but it doesn't worked, because filters use AND implicitly to display information, I need OR.
example:
Code original amount amendment amount
C1 25000 500
C2 2000 18000
C3 14000 9000
C4 12000 10500
Filtering by Original_amount<=10.000 and amendment_amount<=10.000 is noy displaying any records
The result expected is C1,C2 and C3 code records displayed because one og the both conditions is true...
How could I filter for displaying the right data?
Using the example described above, the result expected is C1,C2 and C3 code records displayed because one of both conditions is true...
results expected:
Code original amount amendment amount
C1 25.000 500
C2 2.000 18.000
C3 14.000 9.000
How could I filter for displaying the right data?
Create a calculated measure in the PivotTable which is called Show Row:
IIF(
(
Not(IsEmpty([Measures].[original amount]))
AND [Measures].[original amount] <=10000
)
OR
(
Not(IsEmpty([Measures].[amendment amount]))
AND [Measures].[amendment amount]<=10000
),
1,
Null
)
Then add that calculated measure to your PivotTable and filter to keep only rows where Show Row >= 1.

Power Pivot / DAX - Distinct Count of one dim column from multiple fact tables

Using Power Pivot in Excel 2016
I have one dim table called "Roster" with 218 unique 'Employee Names' and other attributes for the employees
I have three fact tables called "Forecast," "Actual," and "Invoice," each with the related 'Employee Name' columns, in addition to many other attributes and values. I want a distinct count of 'Employee Name' across all three of those tables, depending on what I'd like to pivot them by in my pivot table, like 'Project' or 'Company.' I've read about counting across multiple columns from one table, but I'm trying to count across multiple tables.
When I create measure of:
Headcount:=calculate(DISTINCTCOUNT('Roster_Table'[Employee Name]),'Actual','Forecast','Invoice'), and throw it in my pivot table, I get a very small count of 14, which is probably the ones that are unique to only one of the three tables.
When I create measure of: Headcount:=DISTINCTCOUNT('Roster_Table'[Employee Name]), I get all 218
The true number should be around 170. Any ideas of how to make this work?
Thanks
Please try the following DAX calculation:
COUNTROWS(
DISTINCT(
UNION(
VALUES('Forecast'[Employee Name]),
VALUES('Actual'[Employee Name]),
VALUES('Invoice'[Employee Name])
)
)
)

Power pivot named MDX field

I have a PowerPivot Data Model in Excel 2013. There are several measures that I have grouped into a named set using MDX - something like this:
{[Measures].[Sum of Value1],
[Measures].[Sum of Value2],
[Measures].[Sum of Value3]}
By using this named Set, I can place multiple measures on the rows or columns of an Excel PivotTable in a single action. My question is, is there any way using MDX (or DAX in the PowerPivot screen when working with the individual measures) to filter out or hide the entire set based on a single measure value (whether that measure is included in the set or not)? Preferably, I'm looking for a way to do this without including another member in the set (I.e. Not a measure).
Ror example, if the Sum of Value3 in the above example was zero, I'd want the entire set to be hidden from the pivot table.
I know I could edit the DAX in the Data Model to return BLANK() for each measure included in the set based on the value of another measure, but there may be times I want to show those measures in all cases. This would require writing at least 2 measures for every one I have now which I don't like the thought of doing.
UPDATE:
Sourav's answer looks great, but unfortunately won't work in my particular scenario, I believe, because I'm using the "Create Set using MDX" function (under the Manage Sets option in the Fields, Items, & Sets ribbon menu) within Excel. It will only let me write the MDX as:
IIF([Measures].[Sum of Value3]=0,
{},
{[Measures].[Sum of Value1],[Measures].[Sum of Value2],[Measures].[Sum of Value3]})
And once I add that new set to the PivotTable, it will still display all 3 measures for any members where [Sum of Value3] is 0.
I think I'm going to have to find an approach using DAX and the Excel Data Model measures.
UPDATE 2:
Below is a screenshot to help illustrate. Keep in mind the data source in my example is not an external cube, it's simply an Excel file linked in the Data Model against which MDX queries (with limitations?) can be run. In this example, I would like the set to return only Rows A and C because Sum of Value3 is not zero. However, as you can see, all rows are being returned. Thanks!
You can't choose to hide/unhide members/sets on the fly. Instead, you can use IIF to conditionally return an empty set
WITH SET MyNamedSet AS
IIF([Measures].[Sum of Value3] = 0,
{},
{[Measures].[Sum of Value1],[Measures].[Sum of Value2], [Measures].[Sum of Value3]}
Working example in AdventureWorks for #whytheq(DISCLAIMER - Cube was created by me for testing purposes)
with set abc as
iif([Measures].[Fact Internet Sales Count]>34229,
{
[Measures].[Fact Internet Sales Count],
[Measures].[Extended Amount - Fact Internet Sales]
},
{}
)
SELECT
abc
on 0
from [AdventureWorksDW]
where [Due Date].[Year].&[2004]
As you can see, the scope IS changing the results.
An alternative would be to create a dummy measure that returns null or 1 depending on your [Measures].[Sum of Value3]. Then multiply all other target measures by this dummy measure.
Here is an example of you scenario in AdvWrks:
SELECT
[Product].[Product Categories].[Category].[Components] ON 0
,{
[Measures].[Internet Sales Amount]
,[Measures].[Sales Amount]
,[Measures].[Standard Product Cost]
,[Measures].[Total Product Cost]
} ON 1
FROM [Adventure Works];
Returns this:
Adding the dummy measure and amending the other measures:
WITH
MEMBER [Measures].[isItZero] AS
IIF
(
[Measures].[Internet Sales Amount] = 0
,null
,1
)
MEMBER [Measures].[Sales Amount NEW] AS
[Measures].[Sales Amount] * [Measures].[isItZero]
MEMBER [Measures].[Standard Product Cost NEW] AS
[Measures].[Standard Product Cost] * [Measures].[isItZero]
MEMBER [Measures].[Total Product Cost NEW] AS
[Measures].[Total Product Cost] * [Measures].[isItZero]
SELECT
NON EMPTY //<<<<this is required
{
[Measures].[Internet Sales Amount]
,[Measures].[Sales Amount NEW]
,[Measures].[Standard Product Cost NEW]
,[Measures].[Total Product Cost NEW]
} ON 0
,{} ON 1
FROM [Adventure Works]
WHERE
[Product].[Product Categories].[Category].[Components];
Now this returns:
EDIT
According to your latest edit please just try this (I'm assuming you're using Excel 2013):
Create two new measures to replace two of the existing ones:
Name: "Sum of Value1 NEW"
Definition:
IIF
(
[Measures].[Sum of Value3] = 0
,null
,[Measures].[Sum of Value1]
)
Name: "Sum of Value2 NEW"
Definition:
IIF
(
[Measures].[Sum of Value3] = 0
,null
,[Measures].[Sum of Value2]
)
Now use only these three measures in your pivot and just use the ID dimension in a normal way on rows i.e. do not use the custom set you have already tried.
[Measures].[Sum of Value1 NEW]
[Measures].[Sum of Value2 NEW]
[Measures].[Sum of Value3]
Has ID B should now disappear?

Excel pivot table calculated field total returns unexpected value

I have an Excel spreadsheet which has a pivot table on it. The data itself is quite simple, Number of Units and a Discount (percentage from 0 to 100), pivoted on date across the top and customer down the left hand side. Those numbers are straight from a SQL view, so the pivot table source is just:
SELECT * FROM UnitDiscountView
All was looking fine until I attempted to add a calculated field of TotalCost (Each unit will costs £200) to the pivot table:
= (200 *NrUnits ) * ((100-Discount)/100)
The total at the bottom was negative, and vastly more than I was expecting as a number. If I select all the cells, then the sum which appear in the status bar at the bottom is what I would expect, but the Total field at the bottom is over a hundred times bigger, and negative to boot.
I am stumped. I have searched since Friday without finding anything which will help me to solve this. Any pointers on where to start looking for the solution would be greatly appreciated. I should mention that SQL is my forte, not Excel. I haven't used Excel's Pivot tables before last week, so I am probably missing something really obvious.
Calculated fields will work with the totals:
200 * (Sum of NrUnits) * ((100 - [Sum of Discount]) / 100 )
So for your total row, if Sum of Discount is greater than 100 (adding up all the Sums of Discount on the pivot table), the part of your formula (100-Sum of Discount) will be returning a negative number, hence the negative value.
What I normally do is to add another column to the table to the right of the values returned from the query. I will add my formulas there, then do the pivot table on the resized table.
If you have formatted the returned SQL query as a table (or list in Excel 2003), the pivot table source range should even resize by itself.
I found the answer.
Excel was effectively doing this for the total:
= (200 * sum(NrUnits)) * ((100-sum(Discount))/100)
Which isn't even close to what I wanted:
= sum((200-NrUnits) * ((100-Discount) * 100)))
I got round it by changing the SQL from the view to be:
SELECT *, NrUnits*((100-Discount)*100) AS EffectiveUnits
FROM UnitDiscountView
And the Calculated field to:
= EffectiveUnits * 200

Resources