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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
HB13
Helper I
Helper I

How to adjust DAX measure to include multiple values?

Hi PBI gang

I have this measure;

var Year_ = SELECTEDVALUE(_DateTable[Years])
return
CALCULATE(SUM(Table1[PremiumVAT]), Table2[InceptionDate].[Year] = Year_)
+
CALCULATE(SUM(Table1[PremiumExclVAT]), Table2[InceptionDate].[Year] = Year_)



If my date filter is set with a Date range of the same year (i.e only 2021) then the measure works but if the range is across two years (2020, 2021) then it doesnt work. What do I need to change in order have more than one year value incorporated into the measure?

Many thanks!
1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @HB13 ,

 

Please try this:-

VAR max_Year_ =
    MAX ( _DateTable[Years] )
VAR min_Year_ =
    MIN ( _DateTable[Years] )
RETURN
    CALCULATE (
        SUM ( Table1[PremiumVAT] ),
        FILTER (
            Table2,
            Table2[InceptionDate].[Year] <= max_Year_
                && Table2[InceptionDate].[Year] >= min_Year_
        )
    )
        + CALCULATE (
            SUM ( Table1[PremiumExclVAT] ),
            FILTER (
                Table2,
                Table2[InceptionDate].[Year] <= max_Year_
                    && Table2[InceptionDate].[Year] >= min_Year_
            )
        )

 

BR,

Samarth

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @HB13 ,

 

Please try this:-

VAR max_Year_ =
    MAX ( _DateTable[Years] )
VAR min_Year_ =
    MIN ( _DateTable[Years] )
RETURN
    CALCULATE (
        SUM ( Table1[PremiumVAT] ),
        FILTER (
            Table2,
            Table2[InceptionDate].[Year] <= max_Year_
                && Table2[InceptionDate].[Year] >= min_Year_
        )
    )
        + CALCULATE (
            SUM ( Table1[PremiumExclVAT] ),
            FILTER (
                Table2,
                Table2[InceptionDate].[Year] <= max_Year_
                    && Table2[InceptionDate].[Year] >= min_Year_
            )
        )

 

BR,

Samarth

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi @Samarth_18 

Thank you for your response.
This helped a ton, although I had to adjust the max_ & min_Year variables so that it referenced what the the Date filter was selecting.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.