Forum Discussion
QTY based on the date range
- 1 year ago
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
Please see attached sample pbix.
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
Please see attached sample pbix.
Hello, thank you. It does work with Calendar Table. Is there a way to do it without?
- danextian1 year agoSuper User
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.
- Ania261 year agoHelper IV
Thank you.