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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Hussain
Helper I
Helper I

Calculate sum of data in a date range in Power BI table

Hi,

 

I have a table like this:

Hussain_0-1632456330639.png

 

I want an output table like this:

Hussain_1-1632456382583.png

Meaning,  every row should show the "Consumption" summed over a date range (date range is provided by the user in a date range slicer.The slicer is not shown in the above screenshot) for all the meter types. The requirement is also that we show the date range in each row in  "From Date" and "To Date" columns

 

Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Hussain ,

 

Create two measures:

From Date = CALCULATE(MIN('Table'[Date]),ALLSELECTED('Table'))
To Date = CALCULATE( MAX('Table'[Date]),ALLSELECTED('Table'))

Put the four fields in the table, and then select the aggregation operation of Count in the ConsumptionCount field.

1.png

 

You can filter date by a slicer.

2.png

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Hussain ,

 

Create two measures:

From Date = CALCULATE(MIN('Table'[Date]),ALLSELECTED('Table'))
To Date = CALCULATE( MAX('Table'[Date]),ALLSELECTED('Table'))

Put the four fields in the table, and then select the aggregation operation of Count in the ConsumptionCount field.

1.png

 

You can filter date by a slicer.

2.png

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Hussain , Assume you have independent date slicer, measures like these can help

 

Max Date = MAXX(allselected('Date1'),'Date1' [Date])
Min Date = MinX(allselected('Date1'),'Date1' [Date])

measure =
VAR _max = MAXX(allselected('Date1'),'Date1' [Date])
var _min = MinX(allselected('Date1'),'Date1' [Date])

return
calculate(Sum(Table[ConsumptionCount]), filter(Table, Table[upload Date]>=_min && Table[upload Date]<=_max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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