Left outer join sum with DAX - excel

I have 2 tables:
Fact sales table (sales)
Dimensional period table (dimperiod)
I have joined them through my model on the Period column. However, when I display the sales sum I got this.
I would like to have a row where no sales were made with a sum equal to 0. As below:
I've used the following DAX but didn't work.
CustomSales:=CALCULATE(SUM([Sales]), NATURALLEFTOUTERJOIN(sales,dimperiod))

Just change the pivot table to display blanks.
Or add 0 to your measure. Pivot tables do not display blanks by default. The first option above forces the pivot to display blanks, but you'd need to set this per pivot table. Addition implicitly coerces a blank to a numeric type.
SumSales:=
SUM( 'Sales'[Sales] ) + 0

Related

Multiply and Sum Data from 2 tables based off of Multiple Criteria

In one formula, I am trying to multiply and then sum up data in 2 different tables based off of criteria selected for both tables.
So, if the user picks data from column 1 in the first table but column 3 in the second table, I want to use the corresponding amounts. I tried using Sumproduct but couldn't get it to work.
I used =SUMPRODUCT(ExpenseBase * ExpenseMultiplier*(ModelTypeBase=Type)*(MultiplierTypes=Multiplier))
ExpenseBase is the data in table 1, ExpenseMultiplier is data in table 2, ModelTypeBase is the top labels in table 1 and MultiplierTypes is the top labels in table 1. If I choose X and A, I get the right answer, but if I choose B in the second table it goes to 0.
Base Tables
[1]: https://i.stack.imgur.com/S72yY.png
Use INDEX to return the correct column
Capital:
=SUMPRODUCT(INDEX($B$3:$D$10,0,MATCH($B$17,$B$2:$D$2,0)),INDEX($G$3:$I$10,0,MATCH($B$18,$G$2:$I$2,0)))
Then for Expense we change the lookup ranges:
=SUMPRODUCT(INDEX($B$12:$D$14,0,MATCH($B$17,$B$2:$D$2,0)),INDEX($G$12:$I$14,0,MATCH($B$18,$G$2:$I$2,0)))

Excel VBA macro create new value from 2 entire column

I need to sort values from an entire column.
I do have one column city which have different values of 0 or 1 ( 0% and 100% )
There are 90 000 rows.
I'll need to do a percentage by compiling the values of 0 and 1 by doing the average
I want that value to appear in the column I
Like what I want is that:
You can use AVERAGEIF combined with IF
Function
AVERAGEIF
My fake data:
My formula at C2 (and drag down)
=IF(A2=A1;"";AVERAGEIF($A$2:$A$13;A2;$B$2:$B$13))
Anyways, I would suggest to use indeed Pivot Tables:
Create a PivotTable to analyze worksheet
data
With Pivot Tables, you could group your data using cities field, and then calculate the average easily, and just 1 single row per city instead of those empty rows

How to count the number repeated product purchased by the same customer based on

I have a table with
customer identifier (email)
order number (1 refers to the first order one has placed, 2 is the 2nd)
SKU is the product identifier.
I want to see a table that has two columns:
SKU
the number of times this product has been showed in both the 1st and 2nd order of the same customer. Or in other words, how many times the product has been ordered repeatedly.
Something like this:
What excel function could achieve this?
You can achieve this with a helper column using COUNTIFS, and then a pivot table:
Helper column formula:
=--(COUNTIFS(A$2:A2,A2,C$2:C2,C2)>1)
Add a value filter to the pivot table to only show rows with a value greater than 0.
You can also create a Power Pivot table to count distinct orders and create a measure to count repeat orders.
Here, column F is the Distinct count of customer and column G is the total count of customer for each SKU. Columns H and I are measures you can create with power pivot.

Pivot Table Sum Items, But Average Grand Total

I have a Standard Pivot Table it has Date from the Columns and Numbers in the Value,
Column: Date | Numbers
I want the Numbers in the Rows to be Calculated as Sum, but I want the Grand Total to Average those Sums Rows
How is this possible?
Assuming you have PowerPivot, which you should if you have 2016, and assuming a table called Table1 loaded into the data model, you can add a measure for the sum, called say TotalNumber, which is just:
=SUM(Table1[Numbers])
Then add another measure which is the one you'll use in the pivot table:
=IF(HASONEVALUE(Table1[Date]),[TotalNumber],averagex(VALUES(Table1[Date]),Table1[TotalNumber]))

% of Row Total in pivot table

I'm trying to format my pivot table values as percentages of their row totals (in my data, each quarter). However, when I select Show Values as % of Row Total, it gives each value 100%.
When I try Show Values as % of Parent Row Total, it uses the column as the total and uses the first 4 quarters of 2017 as % total of 2018, not at all what I want to do.
Here is my current pivot table
Here is how I'm trying to format the same pivot table
I didn't type all your "types" (or whatever is in the columns), but when I summarize by % of Row Total, it works as expected.
Is yours set up differently than what I show?
Update
If your data points are all separate columns as #jeffreyweir suggests, then you can't summarize them how you want using pivot table features. You'll have to add some columns to your data
Each Pct column is a formula:
=[#Replacement]/SUM(tbldata[#[Replacement]:[DTK]])
=[#Refund]/SUM(tbldata[#[Replacement]:[DTK]])
=[#Parts]/SUM(tbldata[#[Replacement]:[DTK]])
=[#DTK]/SUM(tbldata[#[Replacement]:[DTK]])
Then you can sum those in a pivot table.

Resources