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

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.

Reply
Anonymous
Not applicable

Set date filter to update with time

I'm doing a calculation to determine what percentage of orders in a period are for a particular product.  It will be plotted against a financial quarter axis, so show growth between this quarter and the previous month.  The report date calculation is robust, accept that as it is.

 

 

ProductTarget = 
VAR ReportDate = IF(ISFILTERED('Backtrack to Previous Month'[End of Previous Month]), FIRSTDATE(ReportingDatePM[ReportingDatePM]), FIRSTDATE(ReportingDate[ReportingDate]))
VAR MonthStart = CALCULATE(STARTOFMONTH('Calendar'[Accounting Date]), FILTER('Calendar', MONTH('Calendar'[Accounting Date]) = MONTH(ReportDate) && YEAR('Calendar'[Accounting Date]) = YEAR(ReportDate)))
VAR NumMonths = SWITCH(MOD(Month(MonthStart), 3),
0, 3,
MOD(MONTH(MonthStart), 3)) + 3
VAR Period =
    DATESINPERIOD ( 'Calendar'[Accounting Date], EDATE(MonthStart, -NumMonths + 1), NumMonths, MONTH )

VAR ProductUnits = CALCULATE([UnitSales], FILTER(Items, Items[PRODUCT_SUBGROUP] = [_TopItem]))
VAR NonProductUnits = CALCULATE([UnitSales], FILTER(Items, Items[PRODUCT_SUBGROUP] <> [_TopItem]))

RETURN

CALCULATE(ProductUnits/(ProductUnits + NonProductUnits), Filter('Calendar', 
DATESINPERIOD('Calendar'[Accounting Date],EDATE(MonthStart, 1 - NumMonths), NumMonths, MONTH)
))

 

 

NumMonths is (a value 1 to 3) + 3, so it varies between 4 and 6.  The number of quarters shown should always be 2.  However, the measure returns results for the full period that we have sales in the system....  A few of the intermediate variables also recorded on cards:

 

Untitled.png

 

Values are around what I would expect for each time period, by the way.  Where am I going wrong?

 

Thanks

2 REPLIES 2
daxer-almighty
Solution Sage
Solution Sage

What's the issue here? Have you forgotten to ask the question? 'Cause I can't for the life of me understand it.

Anonymous
Not applicable

Hi!  I appreciate you clarifying.  I'll update the post with more details.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (5,903)