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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Safus09
Regular Visitor

Use two distinct filters and apply sum to data

Hi,  

I want to sum the Amount after using two distinct Period Values coming from two distinct filter. 

Filter1 = Period1 => Select the first date of the period which is 01/01/2023
Filter2 = Period3 => Select the LastDate of the period which is 31/03/2023

The sum should be : 100 + 150 + 200 + 200 + 500 + 600 


My Data : 

PeriodDateAmount
101-01-2023100
121-01-2023150
201-02-2023200
210-02-2023200
317-03-2023500
324-03-2023600
...  
1201-12-20231200
1231-12-20235000



Using a slicer for dates works fine and it's not a big deal. But I don't know how to do the same by seperating the filters. 

Thank you

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @Safus09 

 

Please try this:
I select two date in the filter:

vzhengdxumsft_0-1712201199132.png

Then add a measure:

MEASURE =
VAR _maxDate =
    CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
VAR _minDate =
    CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] >= _minDate
                && 'Table'[Date] <= _maxDate
        )
    )

The result(150 +200 +200 +500) is as follow:

vzhengdxumsft_1-1712201275035.png

Best Regards

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

 

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

What is you create just one slicer for the period (set to the between format).  Select 1 to 3 in the slicer.  Then just write this measure and drag it to a card visual

Measure = sum(Data[Amount])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-zhengdxu-msft
Community Support
Community Support

Hi @Safus09 

 

Please try this:
I select two date in the filter:

vzhengdxumsft_0-1712201199132.png

Then add a measure:

MEASURE =
VAR _maxDate =
    CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
VAR _minDate =
    CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] >= _minDate
                && 'Table'[Date] <= _maxDate
        )
    )

The result(150 +200 +200 +500) is as follow:

vzhengdxumsft_1-1712201275035.png

Best Regards

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

 

Bmejia
Solution Supplier
Solution Supplier

Are you looking for just another slicer for the period like this.  If that is what you want then you need to format the Period column to a numeric value.  Also make sure that you do not have anything but numbers in this column no "...".  Then just add a slicer similar to date slicer and add Period.  

Bmejia_0-1712176706708.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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