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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Gabriel_Pedri
Resolver I
Resolver I

Filtering through Power BI Measures

I have a date calculated through a measure. I want to use this date to return the value of another measure:

 

CALCULATED DATE

 

Date Variation = MAX('Calendar'[Date]) - [PMP]

 

TOTAL STOCK

 

Total Stock =

SUMX(FILTER(

Stock,

(Stock[AccountName] = "account1" ||

Stock[AccountName] = "account2" ||

Stock[AccountName] = "account3"

),

Stock[Value]

 

MEASURE FILTERED BY ANOTHER MEASURE

 

Total Stock PMP =

CALCULATE(
[Total Stock],

FILTER('Calendar',

'Calendar'[Date] = [Date Variation]
))

 

However, the output of Total Stock PMP returns BLANK because of [Date Variation] = 18/11/2022. This happens due to the specific day set by the filter. There are no values in the stock on the 18th.

I want to find a method that does not filter exactly this date but instead only the month and year, thus taking the entire month's range!

I've tried using ALL, STARTOFMONTH, ENDOFMONTH, FORMAT. However, all of them give some kind of error.

1 ACCEPTED SOLUTION

I managed to achieve the final result through this:

 

Total Stock PMP =
VAR month = MONTH([Date Variation])
VAR year = YEAR([Date Variation])

RETURN
CALCULATE(
[Total Stock],
FILTER (
ALL('Calendar'),
'Calendar'[MonthN] = month &&
'Calendar'[Year] = year
)
)

 

Thank you for your attention.

 

Best regards!

View solution in original post

2 REPLIES 2
Corey_M
Resolver II
Resolver II

Personally I usually add something like this to my date table

Corey_M_0-1704904975811.png

in your case it would be month instead of weeks

I managed to achieve the final result through this:

 

Total Stock PMP =
VAR month = MONTH([Date Variation])
VAR year = YEAR([Date Variation])

RETURN
CALCULATE(
[Total Stock],
FILTER (
ALL('Calendar'),
'Calendar'[MonthN] = month &&
'Calendar'[Year] = year
)
)

 

Thank you for your attention.

 

Best regards!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.