Power BI, cumulative sum Monthly Reports display in a Yearly Chart - powerbi

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)

Related

DAX Rolling Average Applying at Year Level, But Not Month Level

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.

Month field is not getting drill down in power bi

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]))

Year over year running month total percentage change in power bi

I've been struggling with this for a while. I need to calculate running month total percentage change year over year. I got it working but its not getting the running total for the month to do the calculation. By the way this is on the graph. Here are my calculations below:
how graph looks
ImprovementIncidentPercentage = 1 - DIVIDE([CurrYearIncidents],[LastYearIncidents],0)
CurrYearIncidents = CALCULATE(count(VW_RI_INCIDENTONLY_PBI[Incident]),
Filter(VW_RI_INCIDENTONLY_PBI,VW_RI_INCIDENTONLY_PBI[EVENTDATE].[Year] =('newsecondyear'[SecondYearValue])))
LastYearIncidents = CALCULATE(count(VW_RI_INCIDENTONLY_PBI[Incident]),
Filter(VW_RI_INCIDENTONLY_PBI,VW_RI_INCIDENTONLY_PBI[EVENTDATE].[Year] = 'newfirstyear'[FirstYearValue]))
The second and first year value is used as slicers for them to be able to pick two years they want to see the percentage improvement on:
slicers to pick what two years to do percent improvement on
I know something has to change CurrYearIncidents and LastYearIncidents so it does the calculation for running total for the month not the monthly total. I am just not sure how to make it work. Here is the close look at the issue.
show as table graph of error
For January the calculation is correct 1-(10/14) = 28.6%
For February it should be 1-(30/29) but instead it does monthly total for february and doesn't add up january so it does 1-(20/15)
To get accumulation values month over month I use this measure:
Cumulative events = TOTALYTD ( count (VW_RI_INCIDENTONLY_PBI[INCIDENT]), VW_RI_INCIDENTONLY_PBI[EVENTDATE].[Date])
Please help!

Compare totals for the same partial date range year-over-year in DAX / Power BI

I'm trying to create a table which shows a sum of monthly values for one year compared to the last year's totals (structured as the screenshot below):
Monthly Comparison
However, the caveat I'm dealing with is comparing the most current month, which will always contain partial month data (unless it's the last day of the month), to the same date range of the previous year. In the screenshot I attached, our data for January 2018 only goes through January 22nd. However, it's comparing it to the full month of January from 2017, whereas we want that total to be January 1st - 22nd, 2017: Value That Needs to be Updated.
I've tried messing around with various MTD and cumulative totals, but I can't seem to get the logic to work while keeping the aggregation to the monthly level. Any idea what type of logic needs to used in order to compare year-over-year totals, but only do a partial sum for the same date range of a month that is currently in progress?
Thanks in advance.
In my short example, this seems to work:
Total Sales LY 2 =
VAR MaxDate = EDATE(CALCULATE(MAX(Sales[Date]);ALL(Sales));-12)
RETURN
CALCULATE(
[Total Sales];
FILTER(SAMEPERIODLASTYEAR('Date'[Date]);'Date'[Date]<=MaxDate)
)
I calculate Total Sales for the same period last year, with the max of the last available sales date this year.
Total Sales LY = Comparing last year full month (wrong)
Total Sales LY 2 = Comparing last year month, with max of last sales date
PBIX file

Calculate revenue by week - sunday to saturday (last year) on tabular cube/Power BI

I have a report on Power BI where data comes from a tabular cube. The DAX expressions are made in the cube. When drilling down in Power BI and comparing results to the original numbers there is a slight difference. Power BI calculates the week figures as monday - sunday, but I want it to show from sunday - saturday
Initial code:
IF(ISBLANK([Revenue]), BLANK(), CALCULATE([Revenue],SAMEPERIODLASTYEAR('Date'[Date]),ALL('Date'[Date])))
The date table in cube contains columns [SortFiscalWeek], [SortFiscalMonth], [SortFiscalYear], [Week Commencing],Fiscal Week Number.
Week Commencing is in accordance to Sunday (being the week commence date) - Saturday.
The sort fiscal columns start as 1 from years ago and end to whichever number it is today based on today's date.
I added Fiscal Week Number as I thought it might be helpful and tried using it as Test New Users LY = IF(ISBLANK([New Users]),BLANK(),CALCULATE([New Users],SAMEPERIODLASTYEAR('Date'[Date]),FILTER(ALL('date'),'Date'[Fiscal Week Number]='Date'[Fiscal Week Number]&&'Date'[YearInt] = 'Date'[YearInt]-1)))
EDIT
In Power BI I am using a Clustered Column Chart with Date Hierarchy in the Axis and Revenue in the Value. On week level it sums the Revenue as Monday-Sunday and not Sunday-Saturday. Hope this clears up some doubt as to how i am using the data in Power BI
Can anyone help?
If I understood well, I had the same problem, I created a calculated column giving me the name of the month, like this:
MonthName = SWITCH(DimDate[Month], 1,"gennaio",2,"febbraio",3,"marzo",4,"aprile",5,"maggio",6,"giugno",7,"luglio",8,"agosto",9,"settembre",10,"ottobre",11,"novembre",12,"dicembre","altro")
then I needed to order the month by month number, so to do this you need to select your calculated column, and then go to the tab Modelling>Sort by column, in this menu you can choose on which field of the table you order the selected field.
Hope that helps.