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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
slyfox
Helper II
Helper II

First and Last date

Dear Community,

 

please help to figure out why my expression not working as expected
Sum of Product = CALCULATE(SUM(Table[Product]),Date=OR(FIRSTDATE(Table[Date]),LASTDATE(Table[Date]))

formula keep to return all sum values in a selected date range.

 

Source  
   
DateProductQty
01-02-18A2
01-02-18B5
01-02-18B6
03-02-18A7
03-02-18A9
03-02-18B2
06-02-18A6
06-02-18A7
06-02-18B9

 

And Expected result

 AB
01-02-18211
06-02-18139
1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi slyfox ,

 

To achieve your requirement, you can create a measure and use DAX below:

Result = CALCULATE(AVERAGE('Table'[Qty]), FILTER('Table', ('Table'[Date] = MIN('Table'[Date]) || 'Table'[Date] = MAX('Table'[Date])) && 'Table'[Date] = EARLIER('Table'[Date]) && 'Table'[Product] = EARLIER('Table'[Product])))

66.PNG

PBIX here: https://www.dropbox.com/s/am1wnov5mng3u4i/First%20and%20Last%20date.pbix?dl=0

 

Regards,

Jimmy Tao

View solution in original post

1 REPLY 1
v-yuta-msft
Community Support
Community Support

Hi slyfox ,

 

To achieve your requirement, you can create a measure and use DAX below:

Result = CALCULATE(AVERAGE('Table'[Qty]), FILTER('Table', ('Table'[Date] = MIN('Table'[Date]) || 'Table'[Date] = MAX('Table'[Date])) && 'Table'[Date] = EARLIER('Table'[Date]) && 'Table'[Product] = EARLIER('Table'[Product])))

66.PNG

PBIX here: https://www.dropbox.com/s/am1wnov5mng3u4i/First%20and%20Last%20date.pbix?dl=0

 

Regards,

Jimmy Tao

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors