Forum Discussion
transfer filter
- 7 years ago
Hi jvandyck
For example, create relationships as below
add "year/month" column from "date table1" to the slicer, then create columns and measure in "fact sales" table
column
year = YEAR('fact sales'[date]) month = MONTH('fact sales'[date])measures
seelcted_year = SELECTEDVALUE('date table1'[year]) selected_month = SELECTEDVALUE('date table1'[month]) ytd_selected = IF ( MAX ( [year] ) = [seelcted_year] && MAX ( [month] ) <= [selected_month], CALCULATE ( SUM ( 'fact sales'[sales] ), FILTER ( ALL ( 'fact sales' ), [year] = [seelcted_year] && [month] <= [selected_month] && 'fact sales'[date] <= MAX ( 'fact sales'[date] ) ) ) )Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi jvandyck
For example, create relationships as below
add "year/month" column from "date table1" to the slicer, then create columns and measure in "fact sales" table
column
year = YEAR('fact sales'[date])
month = MONTH('fact sales'[date])
measures
seelcted_year = SELECTEDVALUE('date table1'[year])
selected_month = SELECTEDVALUE('date table1'[month])
ytd_selected =
IF (
MAX ( [year] ) = [seelcted_year]
&& MAX ( [month] ) <= [selected_month],
CALCULATE (
SUM ( 'fact sales'[sales] ),
FILTER (
ALL ( 'fact sales' ),
[year] = [seelcted_year]
&& [month] <= [selected_month]
&& 'fact sales'[date] <= MAX ( 'fact sales'[date] )
)
)
)
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- jvandyck7 years agoHelper IV
Thanks, this works! however I do not fully grasp the logic...can you try to explain?
Also, what would be the formula if I want to show the mtd value for the selected year?
Many thanks again!!