Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello
Any ideas how i create a measure to show the previous month count.
Thanks
Ross
Solved! Go to Solution.
Hi @rosscortb,
I made one sample for your reference. Please check the following steps as below.
1. Create a date table, and create relationship between it and the fact table.
date = CALENDARAUTO()
2. To create the measure to get the amount of the previous month.
Previous = CALCULATE(SUM(Table1[headcount]),DATEADD('date'[Date],-1,MONTH))
Please check the pbix as attached.
Regards,
Frank
if i need to calculate the last year what should i do
I also have simliar issue as to the OP. I have used the supplied DAX to try and return a count of incidents for the previous month only and I recieve the total count up to the previous month.
I have also used this DAX as a base to try and solve my issue = CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSMONTH('DateTime'[DateKey]))
Any help would be appreciated.
Hi @rosscortb,
I made one sample for your reference. Please check the following steps as below.
1. Create a date table, and create relationship between it and the fact table.
date = CALENDARAUTO()
2. To create the measure to get the amount of the previous month.
Previous = CALCULATE(SUM(Table1[headcount]),DATEADD('date'[Date],-1,MONTH))
Please check the pbix as attached.
Regards,
Frank
Hi,
Similar to your query, mine aims to retrieve the most recent non-blank value. This formula works well and takes the value from the prior month when I input it. However, it won't pick it up if there are two or more consecutive months with a blank value. Can you explain a procedure that does that?
Hi,
Share some data to work with, explain the question and show the expected result.
Hey Ashish,
I was able to find the answer, but I still have a question. The following measure was effective:
Hi,
Try this
Last Non Blank Value =
Var Last_Date =
CALCULATE(MAX(Dates[Date]),
FILTER(ALL(Dates), Dates[Date] <= MAX(Dates[Date]) &&
Query1[Total Sales Values] <> 0))
return
if(min(calendar[date])>=date(2023,10,1),blank(),CALCULATE([Sales Value], FILTER(ALL(Dates),Dates[Date] = Last_Date)))
This gives me an error. 'Too many arguments were passed to the MIN function. Also, it shouldn't stop in October. Every month I update this report and gives me a price for the current month.
return if(min(calendar[date]>=date(2023,10,1),blank(),CALCULATE([Sales Value], FILTER(ALL(Dates),Dates[Date] = Last_Date)))
Hi,
I edited my previous reply - pleease copy that formula again.
Hi Ashish,
That is great! Is there a way to have it stop after the final value? So, for example, I have one category that no longer displays pricing after February 2019. So I'm not going to fill it until October 2023. Similarly, I have another category with a price cap of November 2022, and I want it to stop filling after that date.
Hi,
Share the download link of the PBI file. Clearly show the problematic visual there.
Hi Ashish,
I am unable to share the file. But I can show you the table.
So, in the original, when I pick category 1, it gives me pricing from January 1, 2000, to December 31, 2018. However, you can see the missing month marked in yellow, where I fill in the number from the prior month. So in this case, it would be 115.00, and the 490.00 I indicated is the most recent price change for category 1. So I don't want the measure to fill down from the last number and on.
It may differ for other categories with other dates, and I don't want the measure to fill down after the last price. The formula you gave me contained October 2023, which is obviously what I gave you, but it was only an example. The dates are subject to change.
The table below displays the measure you provided, however as you can see, the fill-down works but continues past 12/2018, which I don't want. I hope this clarifies the situation.
I cannot help you by just reading some text and looking at screenshots.
Hey Ashish,
I understand. I have attached a sample data file. Please find the link below:
https://we.tl/t-4Kf20Fvr6b
Hi Ashish,
Thank you very much. It works perfectly.
I have one last question. How would I be able to get 3 months rolling average for that measure?
The values that are being filled down should be included in the rolling average.
Thanks
You are welcome. Since this is a different question, please start a new thread.
Hi, I beleive there at two challenges with this DAX. It gives not only previous but previous and earlier. And if you have dates in the future it will not return previous but previous from max date. So my question is how to get values from previous month only refered to sysdate/to day?
Previous = CALCULATE(SUM(Table1[headcount]),DATEADD('date'[Date],-1,MONTH))
it doesn't seem to work for me. In your example you have typed in the headcount while my headcount is based on individuals rows so its counting those rows to work out the headcount for each month
Hi @rosscortb,
Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.
Regards,
Frank
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
124 | |
79 | |
50 | |
38 | |
38 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |