Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
XangeleZ26
Regular Visitor

Calculation based on the month and year of the month and year slicer while ignoring the minimum mont

Hello friends, I want to calculate the amount of SOT between the minimum month and year of the entire dataset (not the minimum value of my months and years slicer) and the maximum month and year that is defined in the months and years slicer . This is a picture from my excel (see SOT as product identifier):

XangeleZ26_0-1687626225010.png

This is my current filter:

XangeleZ26_1-1687626309679.png

XangeleZ26_2-1687626362386.png

And this is the DAX I've created (currently it only works if I only filter by years using a years slicer):

 

añoMAX =
var _max = MAXX(ALLSELECTED(Hoja1[FECHA].[Año]),Hoja1[FECHA].[Año])
return
CALCULATE(
DISTINCTCOUNT(Hoja1[SOT]),
FILTER(
ALL(Hoja1[FECHA].[Año]),
Hoja1[FECHA].[Año] <= _max
))

 

I tried adding 'Hoja1' [FECHA]. [Mes] to that formula without success.

NOTE: To avoid errors, I only want the month filter to work for the last selected year. For example, if my last SOT has a record of 06/2023, then if I set a SOT limit until 05/2023, the result would be the total number of SOTs from the minimum date to 05/2023, but if the months for other previous years, such as excluding the month of June 2022, this would not affect the result as long as there is a higher year selected, in this case, 2023.

I appreciate your support, thank you very much.

 

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @XangeleZ26 ,

 

Please try:

Measure = 
var _a = SELECTCOLUMNS('Table',"FECHA",[FECHA])
var _b = MAXX(_a,[FECHA])
var _c = MINX(ALL('Table'[FECHA]),[FECHA])
return CALCULATE(SUM('Table'[SOT]),FILTER(ALL('Table'),[FECHA]>=_c&&[FECHA]<=_b))

Final output:

vjianbolimsft_0-1687832574041.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @XangeleZ26 ,

 

Please try:

Measure = 
var _a = SELECTCOLUMNS('Table',"FECHA",[FECHA])
var _b = MAXX(_a,[FECHA])
var _c = MINX(ALL('Table'[FECHA]),[FECHA])
return CALCULATE(SUM('Table'[SOT]),FILTER(ALL('Table'),[FECHA]>=_c&&[FECHA]<=_b))

Final output:

vjianbolimsft_0-1687832574041.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.