cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pbi07
Helper IV
Helper IV

DAX with Filters on dates for the month

Hello 

 

I am trying to calculate the total for the month based on the below criteria and need some help on how to use the filter

 

I have 2 fact tables. 1 with the Purchases by the date and another for the receipts in the dock which are in the process of being received. Second table is more of a snapshot. This means 1 PO qty will be part of the snapshots taken on multiple dates. 

Based on the selected date, i am trying to total the snapshot table for the totals for the entire month. In the below scenario, if the date selected is 17th Dec, total should look at the snapshot taken on 17th Dec and total quantity for the month. So the expected total will be 75 and exclude Jan quantity 

Pbi07_1-1645157950914.png

 

PBIX is attached.  https://drive.google.com/file/d/13D_NNJiZXOBB9oMJDyXnBYzS5J6t5jzP/view?usp=sharing

 

 

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

In the Purchase snapshot table, i created a calculated column formula

Test = FORMAT(PurchaseSnapshot[Date],"mmyy")=FORMAT(PurchaseSnapshot[Snapshot Date],"mmyy")

Your measure should not be:

On Dock Total = Calculate(sum(PurchaseSnapshot[Quantity]),PurchaseSnapshot[Test]=TRUE())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

In the Purchase snapshot table, i created a calculated column formula

Test = FORMAT(PurchaseSnapshot[Date],"mmyy")=FORMAT(PurchaseSnapshot[Snapshot Date],"mmyy")

Your measure should not be:

On Dock Total = Calculate(sum(PurchaseSnapshot[Quantity]),PurchaseSnapshot[Test]=TRUE())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Pbi07 , Create an independent date table and then try a measure like 

 

//Date1 is independent Date table,
new measure =
var _max = maxx(allselected(Date1),Date1[Date])

return

calculate(sum(Table[Quantity]), filter(Table, Table[Snapshot_date] =_max && eomonth(Table[Date],0) = eomonth(_max,0) ) )



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

@amitchandak  

Tried the measure. But did not work.  Calendar is amrked as a date table and relationship set between Date &  the date in Snapshot table.

new measure =
var _max = maxx(allselected('Calendar'),Calendar[Date])
return
calculate(sum(PurchaseSnapshot[Quantity]), filter(PurchaseSnapshot, PurchaseSnapshot[Date] =_max && eomonth(PurchaseSnapshot[Date],0) = eomonth(_max,0) ) )

 

@amitchandak 

The relation is between calendar [date] & PurchaseSnapshot[SnapshotDate] and the total filtering is on the PurchaseSnapshot[Date] for the beginning to end of the month for selected date. 

 

 

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors