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
ncbshiva
Advocate V
Advocate V

Check whether the Date exists between Current Date and Last 2 month

Hi Team,

 

I want to count the deliveries made between selected month&year and last 2 month&year.

For example i have ordered a phone and it got delivered on 15th May 2019. I have a Date Dimension present in my model and if i select month as "May" and Year as "2019". Then it should check from current + 2 months prior.

 

In the above example my phone got delivered on 15th May 2019 so the delivery date falls between current month and 2 months prior. I want to count these records for the requirement.

 

I have a date dimension and delivery table both are linked by date and delivery date.

 

Please help to achieve this count by writing a Dax formula.

 

Regards

SHIVA

 

 

1 ACCEPTED SOLUTION

@parry2k  Thanks for the reply.

 

As mentioned i have a Date Dimension table and Transaction table where i have product and Delivery Date.

Relationship has been setup between two table with Date and Delivery Date.

Not sure which date to use in the DAX formula.

 

I am using Month and Year filter from the Date Dimension and i need to check whether my delivery date falls between selected Month,Year and the Delivery Date. Please find below the sample data and expected result as delivery count.

 

Delivery DateProduct CodeProductDelivery Count
15-5-201911055Mobile1
10-4-201911055Laptop1
21-2-201911065Ear phone0
5-3-201911077Adapter1

 

Please help me with the DAX expression for this.

 

Regards

SHIVA 

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@ncbshiva try this measure, so if we are checking as of May 2019, it is going to give the deliveries between April , 2019 and May 2019, if you need to change the period, replace -2 in following expression with number of months you want to go back.

 

Deliveries  = 
CALCULATE( COUNTROWS(FACT_TRANSACTIONS ), DATESINPERIOD('Date'[Date], MAX( 'Date'[Date] ), -2, MONTH ) )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  Thanks for the reply.

 

As mentioned i have a Date Dimension table and Transaction table where i have product and Delivery Date.

Relationship has been setup between two table with Date and Delivery Date.

Not sure which date to use in the DAX formula.

 

I am using Month and Year filter from the Date Dimension and i need to check whether my delivery date falls between selected Month,Year and the Delivery Date. Please find below the sample data and expected result as delivery count.

 

Delivery DateProduct CodeProductDelivery Count
15-5-201911055Mobile1
10-4-201911055Laptop1
21-2-201911065Ear phone0
5-3-201911077Adapter1

 

Please help me with the DAX expression for this.

 

Regards

SHIVA 

@ncbshiva use date from date dimension



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.