Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi everyone,
I have a table containing meter readings for several machines:
| Machine | Date | hour |
| A | 01/07/2024 | 1000 |
| A | 10/07/2024 | 1100 |
| A | 23/07/2024 | 1150 |
| B | 09/07/2024 | 200 |
| B | 01/08/2024 | 300 |
| B | 20/08/2024 | 350 |
I would like a DAX measure that could find me the MAX and MIN of the meters for each month for the different machines:
| Machine | Date | hour | MinMonth | MaxMonth |
| A | 01/07/2024 | 1000 | 1000 | 1150 |
| A | 10/07/2024 | 1100 | 1000 | 1150 |
| A | 23/07/2024 | 1150 | 1000 | 1150 |
| B | 09/07/2024 | 200 | 200 | 200 |
| B | 05/08/2024 | 300 | 300 | 350 |
| B | 20/08/2024 | 350 | 300 | 350 |
I have tried to do this formula but due to the large number of rows in the starting table I have resource errors displaying the measure:
thank you in advance
Solved! Go to Solution.
@Tarte What happens if you ditch the ALL in your filter clause?
Calculate =
VAR __Machine = MAX( 'Table'[Machine] )
VAR __Date = MAX( 'Table'[Date] )
VAR __Result =
CALCULATE(
MAX( 'Table'[hour] ),
'Table'[Machine] = __Machine, YEAR( 'Table'[Date] ) = YEAR( __Date ), MONTH( 'Table'[Date] ) = MONTH( __Date )
)
RETURN
__Result
Also, here is a No CALCULATE approach:
NC =
VAR __Machine = MAX( 'Table'[Machine] )
VAR __Date = MAX( 'Table'[Date] )
VAR __Table = FILTER( ALLSELECTED( 'Table' ), [Machine] = __Machine && YEAR( [Date] ) = YEAR( __Date ) && MONTH( [Date] ) = MONTH( __Date ) )
VAR __Result = MAXX( __Table, [hour] )
RETURN
__Result
Hi @Tarte
Thanks for the reply from Greg_Deckler.
The following measures are for your reference.
MinMonth = CALCULATE(MIN([hour]), ALLEXCEPT('Table', 'Table'[Machine]), MONTH('Table'[Date]) = MONTH(MAX([Date])))MaxMonth = CALCULATE(MAX([hour]), ALLEXCEPT('Table', 'Table'[Machine]), MONTH('Table'[Date]) = MONTH(MAX([Date])))
Output:
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Tarte
Thanks for the reply from Greg_Deckler.
The following measures are for your reference.
MinMonth = CALCULATE(MIN([hour]), ALLEXCEPT('Table', 'Table'[Machine]), MONTH('Table'[Date]) = MONTH(MAX([Date])))MaxMonth = CALCULATE(MAX([hour]), ALLEXCEPT('Table', 'Table'[Machine]), MONTH('Table'[Date]) = MONTH(MAX([Date])))
Output:
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Tarte What happens if you ditch the ALL in your filter clause?
Calculate =
VAR __Machine = MAX( 'Table'[Machine] )
VAR __Date = MAX( 'Table'[Date] )
VAR __Result =
CALCULATE(
MAX( 'Table'[hour] ),
'Table'[Machine] = __Machine, YEAR( 'Table'[Date] ) = YEAR( __Date ), MONTH( 'Table'[Date] ) = MONTH( __Date )
)
RETURN
__Result
Also, here is a No CALCULATE approach:
NC =
VAR __Machine = MAX( 'Table'[Machine] )
VAR __Date = MAX( 'Table'[Date] )
VAR __Table = FILTER( ALLSELECTED( 'Table' ), [Machine] = __Machine && YEAR( [Date] ) = YEAR( __Date ) && MONTH( [Date] ) = MONTH( __Date ) )
VAR __Result = MAXX( __Table, [hour] )
RETURN
__Result
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 11 | |
| 10 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |