Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have two datasets, a series of Returns and a series of Shipments. I have a measure calculating the monthly Return Rate over the running total of shipments. I would like to create another measure which is a rolling 6 month average of that Return Rate, but the DAX code I have written is not doing what I want. Its simple enough in Excel but I'm having some trouble with the DAX.
The code I have used:
6 Mo Avg Rate =
VAR NumOfMonths = 6
VAR LastCurrentDate =
MAX ( 'Date'[Date] )
VAR Period =
DATESINPERIOD ( 'Date'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Result =
CALCULATE (
AVERAGEX (
VALUES ( 'Date'[Date] ),
[Return Rate]
),
Period
)
VAR FirstDateInPeriod = MINX ( Period, 'Date'[Date] )
VAR LastDateWithRMA = MAX ( 'RMA'[Date Submitted] )
RETURN
IF ( FirstDateInPeriod <= LastDateWithRMA, Result )
Results I get from that code:
Results I would *expect* to get:
Any tips?
Solved! Go to Solution.
Hi @swisdom
In your date table add a column for Year Month
in your measure replace Date by Year Month
Replace the fields Calendar Year and Month by Year Month
Result
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
In your measure change these 2
Also don't forget to render the column Year Month to Date format
Let me know otherwise I will send you the file.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
Hi,
You may download my PBI file from here.
Hope this helps.
That didn't seem to quite do the trick but its a little more normal?
Hi @swisdom
In your date table add a column for Year Month
in your measure replace Date by Year Month
Replace the fields Calendar Year and Month by Year Month
Result
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
So weird I did exactly that and I'm still getting the same results? Can you take a look at my file below and double check? I see that you got the correct results in your version so I'm not sure what I did wrong.
Well done @Ashish_Mathur 👍
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you @parry2k
In your measure change these 2
Also don't forget to render the column Year Month to Date format
Let me know otherwise I will send you the file.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
That did it, thank you so much!
@swisdom Welcome, eventhough I thought @Ashish_Mathur solution was more close to what you were looking for.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
User | Count |
---|---|
84 | |
76 | |
75 | |
43 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |