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
Hello
I'm creating a measure in Power BI to count the average SKUs a company has from September of last year to the month selected in the data slicer. However, I need you to:
Available data:
Current measures:
Avg. Sku CY (v2) = Medidas[Skus CY (v2)] / [Distribución TOTAL CY]
I've tried several solutions with REMOVEFILTERS(), ALL(), and ALLSELECTED(), but when I change the "Month" filter in Power BI, the measure still gets affected.
How do I write a measure in DAX that counts SKUs from September last year to the selected month, ensuring that the month filter only affects relatively and without losing the other filters?
Solved! Go to Solution.
Hi @Syndicate_Admin ,
To count SKUs from September of the previous year to the selected month of the current year while ensuring that the month filter affects relatively, you can use CALCULATE, FILTER, and DATESBETWEEN in DAX. Since your dataset does not contain a "Year" column and only has a "Calendar Month" column (values 1 to 12), the formula infers the relative year dynamically based on the selected month.
The following measure calculates the distinct count of SKUs while ensuring that SKUs from September to December of the previous year are included when selecting months in the current year. If January is selected, it includes SKUs from September to December of the prior year as well as those in January. For any other month, it accumulates the SKUs from September to the selected month.
Skus CY Adjusted =
VAR SelectedMonth = MAX('Calendar'[Calendar Month])
VAR CurrentYear = YEAR(TODAY())
VAR StartDate = DATE(CurrentYear - 1, 9, 1)
VAR EndDate = DATE(CurrentYear, SelectedMonth, 1)
RETURN
CALCULATE(
DISTINCTCOUNT('Combine CY'[Key spgr]),
FILTER(
ALL('Calendar'),
'Calendar'[Date] >= StartDate &&
'Calendar'[Date] <= EndDate
)
)
This measure works by first determining the selected month from the slicer, retrieving the current year, and calculating the start date as September 1st of the previous year while dynamically setting the end date as the selected month of the current year. The CALCULATE function then filters the dataset to include all SKUs within this range, ensuring that the measure reflects the required logic without being completely overridden by the slicer.
If your data model only contains a Calendar Month column (1-12) without a full date field, you may need to adjust this formula by creating a derived year or using a Year-Month column instead. Let me know if adjustments are needed based on your specific table structure.
Best regards,
Hi @Syndicate_Admin ,
To count SKUs from September of the previous year to the selected month of the current year while ensuring that the month filter affects relatively, you can use CALCULATE, FILTER, and DATESBETWEEN in DAX. Since your dataset does not contain a "Year" column and only has a "Calendar Month" column (values 1 to 12), the formula infers the relative year dynamically based on the selected month.
The following measure calculates the distinct count of SKUs while ensuring that SKUs from September to December of the previous year are included when selecting months in the current year. If January is selected, it includes SKUs from September to December of the prior year as well as those in January. For any other month, it accumulates the SKUs from September to the selected month.
Skus CY Adjusted =
VAR SelectedMonth = MAX('Calendar'[Calendar Month])
VAR CurrentYear = YEAR(TODAY())
VAR StartDate = DATE(CurrentYear - 1, 9, 1)
VAR EndDate = DATE(CurrentYear, SelectedMonth, 1)
RETURN
CALCULATE(
DISTINCTCOUNT('Combine CY'[Key spgr]),
FILTER(
ALL('Calendar'),
'Calendar'[Date] >= StartDate &&
'Calendar'[Date] <= EndDate
)
)
This measure works by first determining the selected month from the slicer, retrieving the current year, and calculating the start date as September 1st of the previous year while dynamically setting the end date as the selected month of the current year. The CALCULATE function then filters the dataset to include all SKUs within this range, ensuring that the measure reflects the required logic without being completely overridden by the slicer.
If your data model only contains a Calendar Month column (1-12) without a full date field, you may need to adjust this formula by creating a derived year or using a Year-Month column instead. Let me know if adjustments are needed based on your specific table structure.
Best regards,
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!