Excel DAX function add value above in column - excel

I'm trying to create a report that shows the current supply of incidents per week. I've got a table "Processing" with 5 columns:
"Year", "Week", "Created", "Closed" and "Supply"
The calculation I need to use is "Created"-"Closed" + "Supply" from the week before (the cell above). In a normal excel table this is easy enough but I can't figure this out with DAX.

To resolve your problem you have to create a index colum on your model. To create the index i create before a yearweek colum, with this calculate column formula:
=[Year]*100+[week]
After that i have create a Index Column with this calculate column formula:
=CALCULATE(COUNT(Tabella1[week]), ALL(tabella1), FILTER(Tabella1;[Yearweek]<=EARLIER([Yearweek])))
the result is this on powerpivot:
after that cou create a calculate column, with this formula:
= [created]+[closed]+LOOKUPVALUE([supply];[Index];[Index]-1)
the result is this:

Related

How to get dynamically the last value from a pivot table in Excel

I have a pivot table like the one in the image:
The table updates every month.
The question is: how can I dynamically get the last value of the table with a function, without VBA?
For example, in this case the last value is -32, just above the "Grand Total" value.
I'm considering to use the function "GETPIVOTDATA" but I don't know how to change the dynamic reference to the last value inserted. At the moment, the formula looks like this:
=GETPIVOTDATA("[Measures].[Count of DESIGNER]";$A$3;
"[Components_Drawings_Data].[DATE (Month)]";
"[Components_Drawings_Data].[DATE (Month)].&[giu]")
Screenshot (below) / here refer.
Assuming:
You can isolate the pivot table so that there are no populated cells
beneath it (reasonable premise, given it's 'dynamic' and so variable
re: # rows)
You're not fixated upon using a PivotTable reference in formula
You do not anticipate any row labels = 'Grand Total' (which would be unusual to say the least, however see alternative function below)
Grand total for columns is displaying
Then the following will achieve what you have indicated:
...how can I dynamically get the last value of the table with a
function, without VBA?
=OFFSET(INDEX($F$4:$F$100,MATCH("grand total", LOWER($F$5:$F$101),0)),0,1,1,1)
Note: the formula in cell L3 in above screenshot includes a wrapper for presentation / ease of use only - i.e. 'Item' (col J) refers to the number of cells 'up' from the Grand Total at the very bottom of the pivot table... e.g. for item = 1 (one level up), 119 is returned (corresponding to 'woman'); for item = 2 (two levels up, 77 displays and so forth.
The corresponding label can be determined in a very similar fashion:
INDEX($F$4:$F$100,MATCH("grand total", LOWER($F$5:$F$101),0)-J3+1)
Alternative/direct (does not rely upon Grand Total for cols):
=OFFSET(F3,COUNTA(F3:F100)-2,1,1,1)
I elaborated this trick.
Suppose the column "Month" of the pivot table corresponds to column A, and the column "Delta" to column B.
I would use this formula:
=INDEX(B:B;MATCH("Grand Total";A:A;0)-1)
It could work.

Can I create a SUMIF with data from either of 2 columns?

I am creating a budgeting table. I am using SUMIF (Category, "Category Name", Amount). However, I have 2 sets of "Amount" - Budgeted and Actual.
How do I make it in such a way that the SUMIF for that Category would add the data from Budgeted if the Actual field is blank?
Try this
check the ";" maybe you have to replace it with a ","
=SUMIFS(Amount;Category;SelectedCategory)+SUMIFS(Budget;Category;SelectedCategory;Amount;"")
Another way to do this is to have a column that represents the value to sum.
New column:
=if(isblank(Amount), Budget, Amount)
Then you just sumifs the new column by category.

How to do a range index and match or vlookup in power pivot excel?

These are the individual data points of the data model:
These are the monthly salaries of the employees (obtained using the pivot table from the data model's data):
Each cell will then be used as the Lookup value which will be run through a table.
The lookup value is to be looked up in column A and column B of the table below and if it is matched (within the range), it will return the corresponding value under column C.
I am unable to find any index and match or vlookup functions in the power pivot functionality of excel using measures--which are used to get some analytics on aggregated values on report objects such as pivot tables.
I have found LOOKUPVALUE( <result_columnName>, <search_columnName>, <search_value>[, <search_columnName>, <search_value>]…) which is a DAX function however, the issue here is that I am doing a range lookup and as shown below, I don't know if you can have an array as an argument to the function.
Traditional calculated fields also do not allow arrays in the formulas.
Lookupvalue() only works on a single column lookups because it will return an empty cell if it cannot find a match as shown below:
But when it does find a match using the table below:
It will work just fine:
First, you need to create a measure for Pay:
Total Pay = SUM(Table1[Pay])
It's important to do it as a measure instead of just dropping 'Pay' into a pivot table (this is called an 'implicit measure' and is concidered a bad practice).
Then, let's say your table with pay ranges is named "Pay Ranges". Create another measure:
Returned Value =
CALCULATE(
VALUES('Pay Ranges'[Value To Return]),
FILTER( 'Pay Ranges',
[Total Pay] >= 'Pay Ranges'[Lower Bound] &&
[Total Pay] < 'Pay Ranges'[Upper Bound]
))
Make sure that all these formulas are Measures, not calculated columns.
Also, the formula relies on the correct construction of the ranges. If they overlap, you will get an error.

Displays incorrect values after created Date Dimension table in Power BI

My Fact table "Premiums" has Premium value and DateTime column (EffectiveDate).
If I look at the Premium by MONTH(EffectiveDate) - it looks correct. Sorry, its not sorted.
But then if I create table Dates, join it to Premiums table on EffectiveDate column and try to look at Premiums by Month - it looks completely different.
I tried two different ways to create Calendar table. Still the same incorrect values.
What am I doing wrong?
It looks to me like you are trying to match a datetime (Premiums[EffectiveDate]) to a date (Dates[Date]), so it's not matching most of your rows.
Try adding a calculated column to your Premiums table that converts EffectiveDate to a date type and then match that up with your calendar table. The following are a few ways that should work for your calculated column:
Calculated Column = Premiums[EffectiveDate].[Date]
Calculated Column = EDATE(Premiums[EffectiveDate],0)
Calculated Column = ROUNDDOWN(Premiums[EffectiveDate],0)
Calculated Column = DATE(YEAR(Premiums[EffectiveDate]),MONTH(Premiums[EffectiveDate]),DAY(Premiums[EffectiveDate]))
Calculated Column = DATEVALUE(FORMAT(Premiums[EffectiveDate],"yyyy/mm/dd"))
Edit: If you don't need the time part of the EffectiveDate column for anything, then just convert both that column and the calendar date column to date types, and it should match up.

DATESYTD returns no value

I have a "sales" table containing all sales data and created a measure:
Total Sales = SUM(std_adi[Nettopreis])
this works fine in power pivot.
Now I want a DATESYTD() measure and used:
Total Sales YTD = CALCULATE([Total Sales], DATESYTD(Dates[Date]))
but when I add this into the power pivot sheet, it contains "no value"
My "Dates" table has a column "Date" and has a relationship to the std_adi table, column order_date (which contains my sales data)
Am I missing something? I have the above DATESYTD formula from a book and looks identical to all the examples on the net
Even if I change the measure to:
=CALCULATE(SUM(std_adi[Nettopreis]), DATESYTD(Dates[Date]))
it contains "no value" which leads me to the point that something with the Dates Table might be wrong, but I can't find anything
It won't have a value unless you slice / filter your pivot by year.
If it still doesn't work check that your Dates table is marked as a Date table. Check that you have a date for every day in the timeframe you are looking at. And check that you can slice your Total Sales measure by Year from your Date table.
Your formula is fine.

Resources