SSAS - Data Warehouse structure and the Unknown value - excel

I have a table that shows summed monthly values grouped by different analysis codes
TableId Month Value Analysis1ID Analysis2ID
1 1 100 1 NULL
2 1 50 NULL 3
3 1 50 2 NULL
4 1 50 3 NULL
I have set the above as a fact table (also have a dimension for the analysis values).
As you can see the table has a new row for each unique ID for the analysis column.
We are then analysing the data in excel, Simply summing the Value column and grouping by Analyis1ID, Month
This give us :
AnalysisID1 1 = 100
AnalysisID1 2 = 50
AnalysisID1 3 = 50
Unknown = 50
Total = 250
This all looks ok apart from the Unknown, which is summed total of NULL....
I have tried excluding the NULL Value in the Dimension by setting the UnknownMember to "Hidden".
This does work but it does not exclude the amount from the total. How can i exclude it from the total value?
I am guessing that the table structure is not correct for that data, I'm unsure though how else to structure it?
Any help or guidance would be appreciated

I would not have NULL values in dimension members, in the past i've always used an Unallocated Member with a -1 ID.
You could then use Cube Security to filter out the Unknown or Unallocated members.

I would Filter that row out using Excel. Right-click on the cell labelled 'Unknown' and you can choose Filter / Hide Selected Items.

Related

Pandas Pivot table prevent filling empty values with 0

I have a pandas DF column (Coded Sentiment (NUM)) that has numerical values, but not all column rows contain a value. See bottom half of the DF some rows are blank.
ContentID Coded Sentiment (NUM)
0 48a799ca7254c59f56daa3aa429f0e250ba294656ab1a6... 0
1 13674042c5f8e452abaddeec1d1509525f4a3cdfb9f3fb...
2 43f821e7431e024ee6b3fe2403847a888f148ffb737f42... -1
3 7f9e89d6c2b5b705ff3d1667410f6d21730424e5d79c52... 0
4 7f9e89d6c2b5b705ff3d1667410f6d21730424e5d79c52... 1
.. ... ...
313 58e18ae5a381450c6f24c5f72c2c71f49e795723d1310f... 1
314 19fd002ffbaab001a0aa2e8c2373aa5a932b6a40510830...
320 b3846c295d5cfe430a8c3faf4078ae7bccb50f1ec7e35e...
321 b3846c295d5cfe430a8c3faf4078ae7bccb50f1ec7e35e...
322 475bae274bcad23ce3947e4c910b20cfae4aad9aea24a8... 1
I need to create a pivot table to sum the numbers for each unique content ID
program_data_sheet_sentiment_fix = program_data_sheet.pivot_table(index='ContentID', values='Coded Sentiment (NUM)', aggfunc= np.sum)
Here is where my problem arises, when I create the pivot table, any rows that don't have any number in the sentiment column returns a 0 in the pivot table for that specific content ID.
What I need is for the pivot table to not add the 0 to any blank values. I need to keep the value blank if there are no numerical values associated to that content ID. This is because blank values and the value 0 both mean something different in my data process so it's important to not add 0 for blank values.
So ideally when I create the pivot table, the content ID found at row index 320 & 321 the sum would simply return a blank value since there is nothing in the sentiment column.
Hope this makes sense.
Can someone point me in the right direction?

DAX returning value based on SUM of multiple rows in other table

Good evening all!!
Here's a fun one. I've been pouring through some other posts and it feels like there are many permutations of this scenario but none that span tables, so I'm looking for some input.
Consider the following:
Table A has two fields: ID and TYPE. TYPE will be our value to populate.
ID Type
1
2
3
Table B has two fields: ASSOCIATED ID and HOURS.
Associated ID Hours
1 24
1 0
2 10
2 38
3 50
3 25
The requirement is to return a value of "LESS THAN 25" or "GREATER THAN 25" for TYPE in TABLE A based on the SUM of the HOURS in TABLE B for the ASSOCIATED ID. Ex: ASSOCIATED ID "1" in TABLE has value 24 and 0 for a sum of 24, returning "LESS THAN 25" for TYPE in item ID 1 in TABLE A.
Any and all suggestions will be attempted, thank you so much to the community for taking a look.
Make sure you have a relationship between the two tables by using the ID. Then enter this formula into a column in the ID table:
Type:=if(calculate(sum(TableB[Hours]))>25,"25 or More","Less than 25")
Try this one on 1-TYPE: (I am considering A1 Cell as the beginning of your table for both table, just place the real position)
=IF(SUMIF(TableB!$A$2:$A$7,"="&A2,TableB!$B$2:$B$7)>=25,"GREATER THAN 25","LESS THAN 25")
Then drag it down.

Excel Vlookup to loop through values until Value is not 0

I have this data,
Roots data
ID Amount
1 *Blank*
1 10
2 20
3 30
transactions data
ID BID
1 ?
2 ?
3 ?
I vlookup the ID into a different sheet to find the Amount for a particular ID. Butt its current only displaying the Amount at the first instead of the ID.
I am using: =vlookup(A2,'Roots data'!F2:G1855,2,FALSE) at the moment.
Give this a try:
=INDEX('Roots data'!$G$2:$G$1855,MATCH(1,INDEX(('Roots data'!$F$2:$F$1855=A2)*('Roots data'!$G$2:$G$1855<>"")*('Roots data'!$G$2:$G$1855<>0),),0))
EDIT: Formula will now ignore results that are 0 as well as blanks.

Multiple Calculated Columns with Filters within Single Pivot Table

I am working to create a Pivot Table in Excel that has multiple calculated fields that take into account whether a condition is true, but cannot figure out how to create this within a single Pivot Table.
Behind the scenes, I have a set of data with a column that can have these values: A,B,C,D,F,L, or R.
I have another column that is a dollar value, and another for Quantity.
I am trying to calculate the price per unit when the Category is A,B, or C, but also calculate the price per unit when the Category is D.
I can create multiple Pivot Tables and tie them to the same slicer, but the issue is this: I need to display the spending in each of the two categories for each location, and when I create two separate Pivot Tables for this, locations that do not have spending in one of the categories are excluded (in this below case, location 2 has no spending in Category D, so it does not show up in the second Pivot Table).
Here is a portion of my data set. The whole data set is over 100,000 rows and will change over time, so I do need a solution for the long-term.
Location Category Volume Quantity
1 A $120.32 6000
3 A $30.08 1300
3 A $60.16 2600
1 B $39.91 1000
2 B $318.50 13000
2 C $196.00 8000
1 D $220.50 8100
3 D $171.50 6300
3 D $35.90 1000
3 D $53.85 1500
2 F $416.50 0
1 L $24.50 0
2 L $30.08 0
1 R $55.13 0
2 R $55.13 0
3 R $110.26 0
Thanks in advance for your help and let me know if I need to clarify anything!
Alright, a little more digging yielded the answer.
A slicer should be included that has all locations selected, then it should be tied to all Pivot Tables in use.
For all Pivot Tables, go to Field Settings, then click on the Layout and Print Tab. Check the box 'Show items with no data'.
Then go to Pivot Table Options and select the values you would like to display for blanks and errors.
I found the solution here.

Grand total for pivot table not giving me the correct amount when using a calculated field

I have a pivot table that I put a calculated field in. the calculation is =IF(fddue_date<finspectData,0,COUNT(fLotSize))
The problem is that instead of getting the expected result of 6 I get 1. Any one have an idea what I am doing wrong?
Row Labels Count of fLotSize Sum of Field1
5/14/2014
5/12/2014 1 0
5/14/2014 7 1
5/15/2014 9 1
5/16/2014 5 1
5/19/2014 3 1
5/30/2014 1 1
6/9/2014 1 1
Grand Total 27 1
This is a side effect of the calculated field and it treats the grand total the same way as any other row in the pivot table.
If you want to use this type of calculated formula and have a sum shown in the grand total, the best way is to create the formula in the source data table and then pull it into your pivot table as a separate column which will show the correct grand total.
it's by the way a known bug since at least Excel 2003. still in 2013 ...
https://support.microsoft.com/en-us/kb/211470

Resources