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
PBIUWO
Helper III
Helper III

SUM with date filters

Hi,

 

I have 2 excel files.

The first one shows the list of quantity demanded for each item by month.

The second one shows the last possible sale date for each item. (There can be no quantity demanded after the specified last sales date. )

 

How can I create a calculation to show how much quantity for each item is being demanded after the specified last sales date?

(I'm having troubles because the last sale date is unique to each item) 

 

Thank you

1 ACCEPTED SOLUTION

Hi,

 

Build a relationship from the Item column of Table1 to the Item column of Table2.  In your visual, drag the Item column from Table2.  Write these measures

 

Last date = MAX(Table2[Last sale date])

 

Quantity sold beyond the last sale date = if(HASONEVALUE(Table2[Item]),CALCULATE(SUM(Table1[Quantity]),FILTER(VALUES(Table1[Plan]),Table1[Plan]>[Last date])),SUMX(SUMMARIZE(VALUES(Table2[Item]),[Item],"ABCD",CALCULATE(SUM(Table1[Quantity]),FILTER(VALUES(Table1[Plan]),Table1[Plan]>[Last date]))),[ABCD]))

 

Hope this helps.

 

Untitled.png


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

View solution in original post

6 REPLIES 6
v-yuta-msft
Community Support
Community Support

@PBIUWO,

 

Could you please share some sample data for further analysis?

 

Regards,

Jimmy Tao

Capture2.PNGCapture.PNGTable 1 has date item number, quantity demanded per month. Table  2 has the Item and the Last Sale Date.

 

I want to create a CALCULATION, where I can see the quantity demanded that is past the last sale date per item.  

Hi,

 

Build a relationship from the Item column of Table1 to the Item column of Table2.  In your visual, drag the Item column from Table2.  Write these measures

 

Last date = MAX(Table2[Last sale date])

 

Quantity sold beyond the last sale date = if(HASONEVALUE(Table2[Item]),CALCULATE(SUM(Table1[Quantity]),FILTER(VALUES(Table1[Plan]),Table1[Plan]>[Last date])),SUMX(SUMMARIZE(VALUES(Table2[Item]),[Item],"ABCD",CALCULATE(SUM(Table1[Quantity]),FILTER(VALUES(Table1[Plan]),Table1[Plan]>[Last date]))),[ABCD]))

 

Hope this helps.

 

Untitled.png


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

Thank you for the reply! 

 

I tried this and have gotten the error, "Too many arguments were passed to the HASONEVALUE function. The maximum argument count for the funciton is 1". 

 

 

Hi,

 

Check your brackets


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

HI @PBIUWO

  Could you please post sample data with expected output? This will help us to help you.

 

Thanks

Raj

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.