ExcelToDAX
Board Regular
- Joined
- Feb 9, 2023
- Messages
- 169
- Office Version
- 365
- Platform
- Windows
I have the following table in Excel:
Lets say this table is called Table1. For the Months 4/1/2024 - 12/1/2024, I want to average the previous two month values. For Example: 4/1/2024 would be 175 (200 + 150), and 5/1/2024 would be 187.5 (200 + 175). I created this function to solve the Excel formula:
If I wanted to achieve this in Power BI DAX, how could I solve the problem?
DATE | VALUE |
1/1/2024 | 100.00 |
2/1/2024 | 150.00 |
3/1/2024 | 200.00 |
4/1/2024 | |
5/1/2024 | |
6/1/2024 | |
7/1/2024 | |
8/1/2024 | |
9/1/2024 | |
10/1/2024 | |
11/1/2024 | |
12/1/2024 |
Lets say this table is called Table1. For the Months 4/1/2024 - 12/1/2024, I want to average the previous two month values. For Example: 4/1/2024 would be 175 (200 + 150), and 5/1/2024 would be 187.5 (200 + 175). I created this function to solve the Excel formula:
Excel Formula:
=REDUCE(FILTER(Table1[VALUE],Table1[VALUE]<>""),FILTER(Table1[VALUE],Table1[VALUE]=""),LAMBDA(a,b,VSTACK(a,AVERAGE(TAKE(a,-2)))))
If I wanted to achieve this in Power BI DAX, how could I solve the problem?