I have the following crosstab using a DMR :
201201
Real Forecast
Car's Revenue XXXX AAA * IGPM
Bike's Revenue YYYY BBB * ISS
and I have a taxes table :
Period Tax %
201201 IGPM 1,5
201201 ISS 0,5
How I calculate the measure Forecast, that depending on the line (account) and period, the rate to be used is different.
Regards
In your Revenue table you must need an item Tax which indicates the Tax used for the Forecast item. Then you can right-click to the crosstab and go to query. Here, you apply a filter like the following :
Revenue.Tax=Taxes.Tax and Revenue.Period=Tax.Period
Finally you create a calculated measure (maybe you cannot make this in a cross tab, so choose a list) Taxes.% * Revenue.Real
Related
I need to divide the weekly budget by the number of working days per week to get a daily target.
The budget table has a structure like:
Area - YearWeek - Budget
The calendar table contains the column "IsWorkingday" with the information regarding the factor (1 for working day)
The following measure is not working:
Budget Phasing = DIVIDE([Budget], SUM('Calendar'[IsWorkingDay]))
[Budget] is a measure that contains the weekly budget.
As you can see in the picture below I get a right value on weekly level.
But I need the same value on a daily level.
daily target = Budget / SUM Workingdays
For example, for 25.05.2020 der should be 56.000 in der Budget Phasing
How can this be achieved?
Joshua, I think you are working with two tables - Budget and Calendar. Both tables are linked in my Data Model by [Week] column (which is a week number).
Try this measure, maybe this will help:
Budget Phasing =
var WeekNo = SELECTEDVALUE(tbl_Calendar[Week])
var WorkingDays = CALCULATE(
SUM(tbl_Calendar[IsWorkingDay]),
FILTER(ALL(tbl_Calendar), tbl_Calendar[Week] = WeekNo))
return
DIVIDE([Budget], WorkingDays)
The result seems to match your requirements:
hope you are doing well and can help solve this puzzle in DAX for PowerBI and PowerPivot.
I'm having troubles with my measure in the subtotals and grand totals. My scene is the following:
I have 3 tables (I share a link below with a test file so you can see it and work there :robothappy:):
1) "Data" (where every register is a sold ticket from a bus company);
2) "Km" (where I have every possible track that the bus can do with their respective kilometer). Related to "Data";
3) and a "Calendar". Related to "Data".
In "Data" I have all the tickets sold from a period with their price, the track that the passenger bought and the departure time of that track.
Each track can have more than 1 departure time (we can call it a service) but only have a specific lenght in kilometers (their kilometers are specified in the "Km" table).
Basically what I need is to calculate the revenue per kilometer for each service in a period (year, month, day).
The calculation should be, basically:
Sum of [Price] (each ticket sold in the period) / Sum of [Km] (of the period considerating the services with their respective kilometers)
I managed to calculate it for the day granularity with the following logic and measures:
Revenue = SUM(Data[Price])
Unique dates = DISTINCTCOUNT(Data[Date])
Revenue/Km = DIVIDE([Revenue]; SUM(Km[Km])*[Unique dates]; 0)
I created [Unique dates] to calculate it because I tried to managed the subtotals of track granularity taking into account that you can have more than 1 day with services within the period. For example:
For "Track 1" we have registered:
1 service on monday (lunes) at 5:00am.
Revenue = $1.140.
Km = 115.
Tickets = 6.
Revenue/Km = 1.140/115 = 9,91.
1 service on tuesday (martes) at 5:00am.
Revenue = $67.
Km = 115.
Tickets = 2.
Revenue/Km = 67/115 = 0,58.
"Subtotal Track 1" should be:
Revenue = 1.140 + 67 = 1.207.
Km = 115 + 115 = 230.
Tickets = 6 + 2 = 8.
Revenue/Km = 1.207/230 = 5,25.
So at that instance someone can think my formula worked, but the problem you can see it when I have more than 1 service per day, for example for Track 3. And also this impact in the grand total of march (marzo).
I understand that the problem is to calculate the correct kilometers for each track in each period. If you check the column "Sum[Km]" is also wrong.
Here is a table (excel file to download - tab "Goal") with the values that should appear:
[goal] https://drive.google.com/file/d/1PMrc-IUnTz0354Ko6q3ZvkxEcnns1RFM/view?usp=sharing
[pbix sample file] https://drive.google.com/file/d/14NBM9a_Frib55fvL-2ybVMhxGXN5Vkf-/view?usp=sharing
Hope you can understand my problem. If you need more details please let me know.
Thank you very much in advance!!!
Andy.-
Delete "Sum of Km" - you should always write DAX measures instead.
Create a new measure for the km traveled:
Total Km =
SUMX (
SUMMARIZE (
Data,
Data[Track],
Data[Date],
Data[Time],
"Total_km", DISTINCT ( Data[Kilometers Column] )
),
[Total_km]
)
Then, change [Revenue/Km] measure:
Revenue/Km = DIVIDE([Revenue], [Total Km])
Result:
The measure correctly calculates km on both subtotal and total levels.
The way it works:
First, we use SUMMARIZE to group records by trips (where trip is a unique combination of track, date and time). Then, we add a column to the summary that contains km for each trip. Finally, we use SUMX to iterate the summary record by record, and sum up trip distances.
The solution should work, although I would recommend to give more thoughts to the data model design. You need to build a better star schema, or DAX will continue to be challenging. For example, I'd consider adding something like "Trip Id" to each record - it will be much easier to iterate over such ids instead of grouping records all the time. Also, more descriptive names can help make DAX clean (names like km[km] look a bit strange :)
I am trying to calculate "Distinct Sum" in DAX Powerpivot. I already have found help here: http://stackoverflow.com/questions/22613333/dynamic-sum-in-dax-picking-distinct-values
And my query is similar but extended further. I am seeking to find solution for such distinct Sum, but via two additional dimension (Month + Country)
In data example below there is Revenue performance on Part Number granularity. in Data there is also Shop Dimension, however Revenue is repeating on shops, is duplicated.
In the post mentioned above there is following solution:
Support:=MAX(Table1[Revenue])
DistinctSumOfRev:=SUMX(DISTINCT(Table1[Part_Num]),[Support])
It is work perfectly if you use Filter/Column/Row: Country and Month.
But if aggregate for All countries, or show performance on whole quarter, then solution will set MAX Revenue thru all countries/Months for and Part Number, which is not correct.
How to include into above solution also those two additional dimensions.
Basically to tell DAX that unique combination is PartNum+Country+Month
Country Month Part_Num Shop Revenue
----------------------------------------
UK 1 ABCD X 1000
France 1 ABCD X 500
France 1 ABCD Y 500
UK 2 ABCD X 1500
UK 2 ABCD Y 1500
UK 1 FGHJ X 3000
France 1 FGHJ X 600
UK 2 FGHJ X 2000
Add a calculated column to your Table1:
PartNumCountryMonth = [Part_Num]&[Country]&[Month]
Then create your measure as follows:
DistinctSumOfRev:=SUMX(DISTINCT(Table1[PartNumCountryMonth]),[Support])
Update
Alternative solution, calculated column is NOT required:
DistinctSumOfRev :=
SUMX ( SUMMARIZE ( 'Table1', [Country], [Part_Num], [Month] ), [Support] )
I'm trying to create a data model in which there are sales people who sell a variety of different product's. The problem comes in with the Tier structure for each product. Some products will receive different points according to sales about. some may have two to three tiers of points depending on sales amount. Other product may just be a flat payout. the then end the sales person gets his finally bounds as a percentage of his points depending on the Tier of number of points he receives for example
Product 1
if volume 100 = 10 points
if volume 200 = 20 points
if volume 300+ = 30 points
employee payout
100 points = 20% of points payout
200 points = 50% of points payout
300 points = 150% if points payout.
I'm not sure how to structure this in the data model and calculate with DAX formula
Thanks for the help in advance
Create new calculated column
Lets Say,
Now you will have
Volume calculated column
(IF ( Volume>=100 then 10 Volume >= 200 then 20)
Person 1 Product 1 100
Person 2 Product 2 200
Person X Product X 300
Then add one more calculated column based on this calculated column to get percentage of volume.
Mark answer as correct if it helps.
Try the following approach:
Data structure
Products:
Sales:
Data model
Load both tables into the Data Model (I called them Products and Sales)
In the diagram view, create a relationship between Sales[Product] and Product[Product]
DAX
This is the ugly part: In the sales table, as a new calculated column with the name Points. Use this DAX formula:
=IF(Sales[Volume]<RELATED(Products[Volume Tier 1]),0,
IF(Sales[Volume]<RELATED(Products[Volume Tier 2]),RELATED(Products[Points Tier 1]),
IF(Sales[Volume]<RELATED(Products[Volume Tier 3]),RELATED(Products[Points Tier 2]),
IF(Sales[Volume]<RELATED(Products[Volume Tier 4]),RELATED(Products[Points Tier 3]),
IF(Sales[Volume]<RELATED(Products[Volume Tier 5]),RELATED(Products[Points Tier 4]),
IF(Sales[Volume]>=RELATED(Products[Volume Tier 5]),RELATED(Products[Points Tier 5])))))))
Add a new measure with this formula: TotalPoints:=SUM(Sales[Points])
Now you can determine the number of points per transaction/sales person/etc. and use this in the subsequent steps.
Instead of using the really Volume Tiers, you could also leave non-relevant tiers blank in the Product table and extend your formula using the ISBLANK function.
I don't know about DAX but this will handle the Excel formulae.
Assuming volume in column A, to calculate points in column B:
$B2 = MIN(10*INT($A2/100),30)
Then I'm assuming you are going to aggregate points somewhere else (let's say in column D) and calculate payout in column E. My preferred way of doing this is to create a small lookup table somewhere. It looks like this:
Points Payout Rate
0 0
100 0.2
200 0.5
300 1.5
Give the lookup table a name, e.g. PayoutRates. The formula to look up the payout rate, and calculate the payout is:
=$D2 * VLOOKUP($D2,PayoutRates,2,TRUE)
Alternatively, you can use nested IF statements to get the same result:
=$D2 * IF($D2<100,0,IF($D2<200,0.2,IF($D2<300,0.5,1.5)))
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