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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors