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
Anonymous
Not applicable

Need to fix the dax query!

Dear Expert, i need to fix my dax. its not working or getting the right value...

 

Requirements:

Period must be possible to change in the Report (Start and End date)

Average stock value:

- Stock value Period Begin:
o Sum (totalcost)
 Filter by ValueDate (All Entries < Period start)

 

- Stock value Period End:
o Sum (totalcost)
 Filter by ValueDate (All Entries < Period End)

 

For example:

Period Start = 01.01.22
Period End = 31.12.22

but the date should be consider from slicer. 

 

I have year 2021, 2022, 2023 and corresponding value.

 

If I select Period Start = 01.01.22 then it will be show totalcost all year 2021<Period Start         ->: sum(totalcost)

 

If I select Period End=12.31.22 then it will be show totalcost all year 2021 + 2022<Period End  -> : sum(totalcost)

 

Now if i select Perido Start then it will comes an error

"A function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

as well as select for  Period end.

 

Begining Stock Value = CALCULATE([totalcost],'ValueDate[Date]<Period Start))
Ending Stock Value = CALCULATE([totalcost],'ValueDate[Date]<Period End))

Please help me in this regards.
3 REPLIES 3
Mahesh0016
Super User
Super User

@Anonymous Can you let me know Which slicer are you use in report ?
For E.g date range Slicer Useing Your Report or not.THANK YOU!!

Anonymous
Not applicable

Not working for me, thanks

Mahesh0016
Super User
Super User

@Anonymous i Hope this helps you!THANK YOU!!
Begining Stock Value = CALCULATE([totalcost],filter(ALLSELECTED('ValueDate[Date]),'ValueDate[Date]<Period Start)))
Ending Stock Value = CALCULATE([totalcost],filter(ALLSELECTED('ValueDate[Date]),'ValueDate[Date]<Period Start)))

ELSE USE THIS


Begining Stock Value = CALCULATE([totalcost],filter('ValueDate'[Date],'ValueDate'[Date]<Period Start)))
Ending Stock Value = CALCULATE([totalcost],filter('ValueDate'[Date],'ValueDate'[Date]<Period Start)))

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.