I have three tables that contain cost: Forecasted Cost, Actual Costs, Invoiced Costs. Each has an "EAC Filter" column for a Y/N of whether to include the cost in an Estimate at Completion, which automatically changes over time and/or as data is added. Here are examples:
EAC from the three tables can be calculated as follows:
Total Cost = Sum(Forecast[Cost])+Sum(Actual[Cost])+Sum(Invoice[Cost])
EAC = Calculate([Total Cost],EAC_Filter[EAC Filter]="Y")
I have a budget at the "Account" level, which could also be rolled up to a "Dept" level budget.
I need a measure for my Power Pivot table which will display the week at which costs have exceeded, or are forecasted to exceed 75% of the budget, using some sort of a cumulative cost, combined with the max week where cumulative cost >= .75 * Budget.
The weeks are numbered through the year as follows:
Thanks for your help!
Given an EAC measure which sums the cost per week,
EAC = CALCULATE(SUM(Forcast[Cost]) + SUM(Acutal[Cost]) + SUM(Invoice[Cost]),
EAC_Filter[EAC Filter] = "Y")
You can create a Cumulative Cost measure as follows:
Cumulative Cost = CALCULATE([EAC],
FILTER(ALL('Calendar'), 'Calendar'[Week] <= MAX('Calendar'[Week])))
Using this, we can create a measure that predicts the week the cost exceeds 75% of the budget:
75% Week = MINX(FILTER(ALL('Calendar'), [Cumulative Cost] > 0.75 * SUM(Budget[Budget])),
'Calendar'[Week])
Here's what the relationships structure looks like:
Related
I have created two calculation groups in an azure analysis ( B0 ) environment. The first one is a list of measures that represent a score card. Most lines use the SELECTEDMEASURE(), but a few of them have a hard measure selected. The other calculation group has some Time intelligence (YTD, Prior Year & variances in % ) as well as a split in Actual and Budget. This is what the result looks like if i put a simple Amount measure ( SUM('fact'[Amount]) ) in.
Result of Visual
The logic in the measures is not ground breaking, these are the elements of the time structure:
Period Actuals: CALCULATE(SELECTEDMEASURE();'Fact'[Version]="Actuals")
Period Budget: CALCULATE(SELECTEDMEASURE();'Fact'[Version]="Budget O")
Period Variance: CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="Period Actuals") -CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="Period Budget")
Period Variance % :Divide(
CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="Period Variance") ;
CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="Period Budget")
;0)
YTD Actuals: CALCULATE(SELECTEDMEASURE();DATESYTD('Calender'[Date];"12-31");'Structure'[Structure] = "Period Actuals")
YTD Budget: CALCULATE(SELECTEDMEASURE();DATESYTD('Calender'[Date];"12-31");'Structure'[Structure] = "Period Budget")
YTD Current Variance: CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="YTD Actuals") - CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="YTD Previous Year")
YTD Current Year: CALCULATE(SELECTEDMEASURE();'Structure'[Structure] = "YTD Actuals")
YTD Previous Year: CALCULATE(SELECTEDMEASURE();DATESYTD(SAMEPERIODLASTYEAR('Calender'[Date]);"12-31");'Structure'[Structure] = "Period Actuals")
YTD Variance: CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="YTD Actuals") - CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="YTD Budget")
YTD Variance %: Divide(
CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="YTD Variance");
CALCULATE(SELECTEDMEASURE();'Structure'[Structure]="YTD Budget")
;0)
The measure in the P&L structure are alse quite simple, here are some examples:
Gross Margin WG : CALCULATE ( SELECTEDMEASURE(); GLAccount[Level03 code] = "PL00_00")*-1
Gross Margin WG - Cranes : CALCULATE ( SELECTEDMEASURE(); GLAccount[Level03 code] = "PL00_00";'Fact'[MachineType] = "LBCC")*-1
Quantity Cranes: CALCULATE ( sum('Fact'[Qty]); GLAccount[Level04 code] = "PL00_00_000";'Fact'[MachineType] = "LBCC")
The model is quite small, SQL Management studio estimates its size to about 250MB.
The issue is that when we are using one of the names calculation groups we get normal responds times ( 2 seconds at most ) but when we use both it can take up to several minutes to get a result in Power BI. Excel is faster, but still takes up to 30 seconds.
Meanwhile the memory consumption in AS goes up by several GB ?!?
This becomes worse when navigating ( filtering or adding dimensions ) up to the point where PowerBI just stops working.
We have tried changing the DAX formula's but we can figure out why it is using so much memory. Hope one of you can send us in the right direction.
Thanks!
I'm given gm%, gm&, sales, sales cost, and several of the same dates. For every date, I want to find the total Gross Margin Percentage for that day. How can I do that in Excel? I want my output to list a unique date and the GM% corresponding to the date.
You can't average gross margin percentages and get an accurate figure. You need the total cost and total retail (/selling price) amounts, and with the total cost and retail amounts you'll be able to calculate the average gross margin percentage with 1-Sum([Cost])/Sum([Retail]).
Averaging percentages is not accurate reporting. Proof:
Units Cost Retail GM%
10 379 1000 62.1%
1 327 650 49.7%
The "average" GM% you would be aggregating would be 55.9%...
but the correct GM% would be 57.2%.
If all you have is the total sales amount and the GM%, you need to compute the total cost:
[Cost$] = [GM%]*[Retail$]
If all you have is the total cost amount and the GM%, you need to compute the total retail:
[Retail$] = [Cost$]/(1-[GM%])
If you have the GM$ amount and the GM%, you can calculate both cost and retail amounts:
[GM%] = [GM$]/[Retail$]
[GM$] = [Retail$]-[Cost$]
[Retail$] = 1/[GM%]*[GM$]
[Cost$] = 1/[GM%]*[GM$]*(1-[GM%])
With these, you can now accurately compute the average GM% figure.
Take a simple table
SalesTime
Product
UnitsSold
There is one row per sale. So there are multiple rows per day. I need a chart that will show the average units sold per sale over 7 days and average units sold per day over 7 days.
The examples that I found all used DATESBETWEEN or DATESINPERIOD and those throw an error if the table has multiple records per date.
I will name this table Sales and assume that Sales[SalesTime] is a date type rather than a datetime type. If not, create a new calculated column
Sales[SalesDate] = Sales[SalesTime].[Date]
and work with that instead.
Your rolling average units per sale can be calculated something like this:
AvgUnitsPerSale =
VAR CurrDay = MIN(Sales[SalesTime])
RETURN CALCULATE(
AVERAGE(Sales[UnitsSold]),
DATESBETWEEN(Sales[SalesTime], CurrDay-7, CurrDay))
You can get an average count of sales per day by using COUNT instead of AVERAGE. To get the average units sold per day, multiply the average count of sales and the average units per sale.
I have 2 Calculated Member AVG Weekly Percentage and AVG Monthly Percentage.
For weekly the Result is Good
And for AVG Monthly Percentage there is error on Grand Total because there is the addition of a grand total of AVG Weekly percent.
the real result AVG(99.83%+85.59%+99.80%+100%+100%+100%) = 97.54%
but the Result from Cube (AVG(99.83%+85.59%+99.80%+100%+100%+100% + 100% (from weekly grand total)) = 97.89%
For AVG Weekly Percentage
IIF(
isempty([Measures].[Actual Quantity MTD]) or [Measures].[Actual Quantity MTD]=0 or isempty([Measures].[Original Plan Quantity MTD]) , null ,
IIF([Measures].[Original Plan Quantity MTD] =0 or
isempty([Measures].[Original Plan Quantity MTD]),null,
IIF(
([Measures].[Actual Quantity MTD]-[Measures].[Original Plan Quantity MTD]) > 0 , 1 ,[Measures].[Actual Quantity MTD]/ [Measures].[Original Plan Quantity MTD]
and for AVG monthly Percentage
AVG (
DESCENDANTS([PSL Scenario].[PSL Scenario Description])*
DESCENDANTS([Plant].[Plant])*
DESCENDANTS([Finish Date].[Calendar],[Finish Date].[Calendar].[Month Year])
, AVG(([Finish Date].[Calendar].CURRENTMEMBER.CHILDREN), [Measures].[AVG Weekly Percentage]))
What do i miss?
You may have to exclude the 'weekly grand total' (as you call it) from the calculation.
I have had situations like this, where I tell the calculation to only use values if they are from the leaf level (or a particular level) of the hierarchy. Can you do this?
I want to Calculate profit margin from Dynamics GP Database.
Which fields or table been used. and How Can I do that.
If any one have an idea please share with me.
In general, there are many different ways to calculate gross profit margin. Be sure you are using the method which is accepted by your companies accounting policies.
Here is an example which looks at all invoices which have been posted year to date and calculates the gross profit margin percentage.
Assuming gross profit margin = total profit / total revenue.
SELECT ( SUM(SUBTOTAL) - SUM(EXTDCOST) ) / SUM(SUBTOTAL)
FROM SOP30200 t1
WHERE t1.SOPTYPE = 3
AND t1.DOCDATE BETWEEN '1/1/2013' AND GETDATE()
This will return a decimal number like .44323. In that case you would be making an average gross profit margin of 44% for every invoice year to date.
SOP30200 = posted sales transaction documents