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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
ahmed_MEJRI
Helper I
Helper I

Calculate sum(amount) with 2 different periods (2 slicers)

Hello Experts, i have an issue and i'm searching all forums and videos but not resolved : calculate the same sum with 2 differents periods .
i tried to use a single table with two columns : date_11 / date_22 and make my measures --> not worked. 
I tried to change the model : with 2 date tables : the first have a column date_11 and and the second have the column date_22 --> not worked also
 
i tried to use a single table with two columns : date_11 / date_22 and make my measures --> not worked
I tried to change the model : with 2 date tables : the first have a column date_11 and and the second have the column date_22 --> not worked also
It's my urgent need : calculations in two different periods (not same period last year or ParellelPeriod)
 
capt bi.png
4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @ahmed_MEJRI ,

I have created a fact table like this:

sample1.png

A date table by this measure:

Calendar = CALENDAR("2020/4/30","2020/6/15")

Create a measure like this and use two slicers:

Measure = 
VAR _minA =
    CALCULATE ( MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
VAR _maxA =
    CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
VAR _minB =
    CALCULATE ( MIN ( 'Table'[date] ), ALLSELECTED ( 'Table'[date] ) )
VAR _maxB =
    CALCULATE ( MAX ( 'Table'[date] ), ALLSELECTED ( 'Table'[date] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[value] ),
        'Table'[date] >= _minA
            && 'Table'[date] <= _maxA,
        'Table'[date] >= _minB
            && 'Table'[date] <= _maxB
    )

date re.png

Here is my sample file that hopes to help you: Calculate sum(amount) with 2 different periods.pbix

 

Best Regards,
Yingjie Li

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

@ahmed_MEJRI , refer if this can help

https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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

@amitchandak 

thanks for this idea , is it possible to use 2 sum measures (different periods , slicers) and calculate the variance in a single table : it will be fantastic : how can we do that ?

@ahmed_MEJRI , can explain with an example. I thought this what needed

https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors