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
CarlBlunck
Resolver I
Resolver I

Sum of values where max id is less than dynamic date

Hi everyone,

 

I am struggling to develop a measure that sums the values where the max id of the value is less than a dynamic date.  Let me explain.  I have the following data set:

 

invoiceidSimpro jobiddateinvoiceissuedWorkInProgress
81823784.AU8/02/2022$222,588.00
85483784.AU27/04/2022$185,088.00
85613784.AU29/04/2022$110,088.00
95573784.AU2/11/2022$35,088.00
84673908.AU4/04/2022$243,438.24
84683908.AU4/04/2022$191,039.68
88183908.AU17/06/2022$113,632.94

 

I have the dateinvoiceissued connected to a MasterCalendar and I need to be able to sum the WorkInProgress values based on the max (invoiceid) for each Simpro jobid where the dateinvoiceissued is less than the date chosen from the MasterCalendar date.

 

Expected outputs based on a date chosen of:

- 10/02/2022 = $222,588

- 05/04/2022 = $413,627.68

- 29/04/2022 = $310.127.68

- 17/06/2022 = $223.720.94

- 03/11/2022 = $148,720.94

 

Appreciate the help in advance!

Thanks

Carl

6 REPLIES 6
Anonymous
Not applicable

Hi @CarlBlunck ,

I could not access this url: https://drive.google.com/file/d/1n4Jbbml3_nw4UmdByPYTeOD2bhPiJ2B1/view?usp=sharing , please reshare.

Thanks for your efforts & time in advance.

 

Best regards,
Community Support Team_Binbin Yu

Anonymous
Not applicable

Hi @CarlBlunck ,

Sorry, i don't have google account, so couldn't access it.

 

Best regards,
Community Support Team_Binbin Yu

TobyNye
Resolver II
Resolver II

I made a sample data set with the small table that you provided and I believe the following suits your needs:

TobyNye_0-1700043198640.png

The measure works by effectively creating a table with unique Simpro Job ID's, finding the max invoice date per row and the work in progress value in that row, it then sums each row of the table, the MAX at the end is just to return only the specific value in the table reference, more examples:

TobyNye_1-1700043340185.pngTobyNye_2-1700043429029.png

The only thing to be wary of is that the date filter is on or before and not just before, I'm using the date column in the table but if you have your main calendar table linked, just use that one in the slicer instead and you should be all fine, raw measure code:

Test =
VAR _table = SUMMARIZE('Fact Table', 'Fact Table'[Simpro Job ID], "invoice id", MAX('Fact Table'[Invoiceid]), "WiP", CALCULATE(SELECTEDVALUE('Fact Table'[Work in Progress]), 'Fact Table'[Invoiceid] = MAX('Fact Table'[Invoiceid])))
RETURN
SUMX(_table, MAX([WiP]))
 
Hope this helps, let me know if you have any issues/questions

Hey @TobyNye - after further validation this didn't work out so well.  I read this article about summarize All the secrets of SUMMARIZE - SQLBI and I think the issue is being cause by all of the other columns in my data set.  I am trying other methods out, but if you have an alternative, would be good to see it.  Here is the PBIX file I am trying to get this working in - https://drive.google.com/file/d/1n4Jbbml3_nw4UmdByPYTeOD2bhPiJ2B1/view?usp=sharing 

That's awesome mate, thank you!! Really appreciate you taking the time to help 🙂 

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! Prices go up Feb. 11th.

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.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.