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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pbi07
Helper V
Helper V

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) ) )

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.