I am calculating total revenue over the years.
There are two tables calendar and sales. I have calculated total revenue using DAX now I want to display total revenue in each year.
The month field is not getting filtered for the Revenue column, I have attached a snip for reference.
Total revenue(DAX)= total revenue = SUMX(AW_Sales,AW_Sales[OrderQuantity] * RELATED(AW_Products_Lookup[ProductPrice]))
Related
I am trying to get a rolling 3/6/12 month average of revenue by month using DAX in a SSAS Tabular model. There is a date table in my model and I have created inactive links between my fact table and my date table for each date in the fact (Date of Service, Invoice Date, etc.). I have created a measure that uses USERELATIONSHIP to activate the specific link I need.
Revenue by DOS:=
CALCULATE( [Total Gross Revenue],
USERELATIONSHIP(D_DATE[W_DT_ID],Fact_Charge[W_SERVICE_DT_ID])
)
Here is the code I am using to create the rolling average, which I copied from a SQLBI video on the same subject:
Net Revenue R3M:=
VAR NumOfMonths = 3
VAR LastSelectedDate = MAX(D_DATE[Calendar_Date])
VAR Period =
DATESINPERIOD( D_DATE[Calendar_Date], LastSelectedDate, -NumOfMonths, MONTH)
VAR Result =
CALCULATE(
AVERAGEX(
VALUES(D_DATE[Month Year]),
[Revenue by DOS]
),
Period
)
Return
Result
For some reason when I deploy the model and try to use it in Power BI, it runs this rolling average at the year level, but not the month. For instance, the Power BI matrix visual will show the year 2021 and will have a value that is equal to the average of the last 3 months of 2021, but the individual months show the same value that is contained in the Revenue by DOS measure itself.
Snip From Power BI
The goal is to have each individual month in the Revenue R3M column to be the 3 month average of the Revenue by DOS column.
The source table has a table with a single amount and a revenue start and revenue end date. I need to graph the amount over the period by day in PowerBI.
For example:
Looking at the second row the total amount is 730 but I need to calculate a daily rate and display this each day for the revenue period. So if I had a bar chart for this row I would need to show it as 16 April has 34.76, 17 April has 34.76 and so on until 6 May which is the revenue end date. I've tried using between dates but cant seem to get it working.
You can use Power BI's CALENDAR() function to create a table of dates ranging from the minimum revenue start date to the maximum revenue end date.
Dates = CALENDAR(MIN(BookFees[Revenue Start Date]),MAX(BookFees[Revenue End Date]))
Then you can create a calculated column in the Dates table for the daily revenue.
Daily Revenue = Calculate(SUM(BookFees[RevenueDayAmount]),FILTER(BookFees,BookFees[Revenue Start Date]<=Dates[Date] && BookFees[Revenue End Date]>= Dates[Date]))
Here is the resulting bar chart:
In Power BI, I have a bunch of cumulative sum monthly reports example current Employee count
so in line charts, it automatically shows the dates as years in the X-axis. you can drill down to see the monthly details of any year. by default the chart SUM all the months to show the year. i want the chart to show the last month's value from every year at the year level
if I showed the report in a line chart
at monthly level ( no issue) if i dril up
at year level (it should show the value for December , PBI "SUM" the values which is wrong,)
I tried
count for December =
CALCULATE(
SUM('data'[count]),
'data'[Date].[Month] IN { "December" },
ALL('data'[Date].[MonthNo])
)
at year level ( no issue) if i drill dawon
at month level (it should show the value for December for all months)
I am trying to calculate the Cumulative Purchases by YTD. The first step is to rank the items by Cost Amount, but when I try to rank by the [_YTD Cost] measure, the numbers I get do not make sense (skipped numbers, duplicated).
[]
I had 3 slicers: Month, Year and to select Month/YTD measures. Since with the Month calculation I have no problems, I removed the interaction with the Month/YTD slicer and I placed only YTD measures on the table:
Total Purchase Cost = SUM ( Purchases[Amount] )
_YTD Cost = TOTALYTD([Total Purchase Cost], 'dim-calendar'[Date])
_RANK YTD = RANKX(ALLSELECTED(Purchases), [_YTD Cost])
Notes:
I pulled the item from the Item table
The Purchase table is linked to the Date table by Purchase Date
Not 100 % sure on your data model, but try changing your RANKX(ALLSELECTED(***) to reference the Item-column. Like this:
RANKX(ALLSELECTED('Item'[Item]), [_YTD Cost])
I have put on the dashboard of Power Bi a matrix with years on columns, district areas on rows and total actual revenue, absolute growth and percentage growth on the last year as values. Why don't I see the absolute growth for each district? I'm using also years as parameter
M-CY_Sales = CALCULATE(sum('Detail Sales Report'[Total Actual Revenue - Base]);filter('Detail Sales Report';'Detail Sales Report'[fiscal Year]=CurrentYear[CurrentYearValue]))
M-PY_Sales = CALCULATE(sum('Detail Sales Report'[Total Actual Revenue - Base]);filter('Detail Sales Report';'Detail Sales Report'[fiscal Year]=CurrentYear[CurrentYearValue]-1))
M-PY2_Sales = CALCULATE(sum('Detail Sales Report'[Total Actual Revenue - Base]);filter('Detail Sales Report';'Detail Sales Report'[fiscal Year]=CurrentYear[CurrentYearValue]-2))
M-PY_Growth = calculate([M-PY_Sales]-[M-PY2_Sales];'Detail Sales Report')
M-PY_Growth% = DIVIDE([M-PY_Growth];ABS([M-PY2_Sales]))
M-CY_Growth = [M-CY_Sales]-[M-PY_Sales]
M-CY_Growth% = DIVIDE([M-CY_Growth];ABS([M-PY_Sales]))
I believe the issue is here:
M-PY_Growth = calculate([M-PY_Sales]-[M-PY2_Sales];'Detail Sales Report')
Using calculate in this form has an implicit inclusion of the ALL() function around the filter term which will strip out the context of the rows the measure sits within.
To override this try:
M-PY_Growth = calculate([M-PY_Sales]-[M-PY2_Sales];KEEPFILTERS('Detail Sales Report'))
If that doesn't work you may need to experiment with ALLEXCEPT() to selectively keep district as a filter but allow the year context to be adjusted.