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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Ania26
Helper III
Helper III

QTY based on the date range

Hello, I would like to have a table where 1 column show total quantity and the other sum of QTY based on the date range that can be selected. How to do it?

1 ACCEPTED SOLUTION

hi @Ania26 

I added more rows to your sample table.

First, create a separate dates/calendar table and create a one to many single direction relationship from that to your fact table joining on their respective date columns.

Create either of these measures that modify the filter context on DatesTable:

 

Qty 2023-2024 = 
//total qty for 2023-24 regardless of the date range selected
CALCULATE (
    SUM ( 'DataTable'[QTY] ),
    FILTER ( ALL ( DatesTable ), DatesTable[Year] IN { 2023, 2024 } )
)


Qty All Dates = 
//total qty for all dates regardless of date range selected
CALCULATE ( SUM ( 'DataTable'[QTY] ), ALL ( 'DatesTable' ) )

 

Create another measure that responds to the date slicer selection:

 

Qty Selected Dates = 
SUM ( 'DataTable'[QTY] )

 

 

Use the date column from the dates table and the fruit column from your fact table and the measures

danextian_0-1733232537062.png

Please see attached sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

11 REPLIES 11

Ajithkumar_P_05_1-1733289015797.png

Ajithkumar_P_05_2-1733289060444.png

 


Try this meaure

 

Anonymous
Not applicable

Thanks for the reply from danextian , please allow me to provide another insight: 
Hi  @Ania26 ,

 

Here are the steps you can follow:

1. Create measure.

All Dates =
COUNTX(
   FILTER( ALLSELECTED('Table'),[Fruit]=MAX('Table'[Fruit])),[Date])
Dates from 2023 till 2024 =
SUMX(
    FILTER(ALLSELECTED('Table'),[Fruit]=MAX('Table'[Fruit])),[QTY])

2. Result:

vyangliumsft_0-1733286642674.png

 

Best Regards,

Liu Yang

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

Hello, thank you for your post. When I use dates filter in your pbix then numbers are changing for both columns when TTL QTY should be constant despite of the selected date range. 

danextian
Super User
Super User

Hi @Ania26 , You mean if you hava row with dates from Jan 1  to Jabn 31, a column that will show the total for the whole month regardless of the date and another column showing the total for each date?  Please provide a workable sample data and your expected result from that.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Ania26_0-1733225271465.png

One column with TTL QTY, all dates, second column with QTY beased on the date range

Your sample data please.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

FruitDateQTY       
A3/3/20231       
B3/3/20242       
A2/2/20213       
b2/2/20214    FruitAll DatesDates from 2023 till 2024
       A41
       B62

 

Last column would change depending on the date selection

hi @Ania26 

I added more rows to your sample table.

First, create a separate dates/calendar table and create a one to many single direction relationship from that to your fact table joining on their respective date columns.

Create either of these measures that modify the filter context on DatesTable:

 

Qty 2023-2024 = 
//total qty for 2023-24 regardless of the date range selected
CALCULATE (
    SUM ( 'DataTable'[QTY] ),
    FILTER ( ALL ( DatesTable ), DatesTable[Year] IN { 2023, 2024 } )
)


Qty All Dates = 
//total qty for all dates regardless of date range selected
CALCULATE ( SUM ( 'DataTable'[QTY] ), ALL ( 'DatesTable' ) )

 

Create another measure that responds to the date slicer selection:

 

Qty Selected Dates = 
SUM ( 'DataTable'[QTY] )

 

 

Use the date column from the dates table and the fruit column from your fact table and the measures

danextian_0-1733232537062.png

Please see attached sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello, thank you. It does work with Calendar Table. Is there a way to do it without?

You can use

Qty All Dates = 
CALCULATE ( SUM ( 'DataTable'[QTY] ), ALL ( 'DataTable'[Date] ) )

Please note that the filter modifier is applied to 'DataTable'[Date] so if there are filters coming from other  date-related dimensions in your fact table, that will not show the value for all dates anymore.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors