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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
rashesh
Frequent Visitor

CALCULATE function with DATEBETWEEN function showing NULL values

Hi All,
I have three tables ("Date Table", "Inventory", and " sales" ). I want the last 30 days' sales of quantity for each item from the "current date"(This column in the "Inventory" table). I have tried but it showing blank.

 Sales TableSales Table

Date TableDate TableInventory TableInventory Table                                                                   
   I have tried the below measures 

-30.png
                 

 

 

 

 

 

 

 

MY OP:-
eOP.png

 

 

 



 

 

 

And please tell me why this is happening and what's the solution. 

Thank you!! @amitchandak @Ashish_Mathur @ValtteriN 

 

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Your question is not clear.  Share data in a format the can be pasted in an MS Excel file and show the expected result.


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

1, you need to mark Calendar Table as Date Table

2, Create one-to-many relationship from Calendar to Inventory, and to Sales

3, try this measure

 Last30Days=VAR _date=Max(Inventory[Current Date]) VAR _item=MAX(Inventory[Item_ID]) RETURN CALCULATE(SUM(Sales[Quantity]),DATESINPERIOD(Calendar[Date],_date,-30,DAY),Sales[ItemID]=_item)

Hi Daniel,
Thanks for Ans but it is not working. and still getting the same error as before.
And for your second point I can not able to make the relationship between the calendar and inventory and when I try to it is creating inactive.


Re.png


 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.