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
Anonymous
Not applicable

Filter Between 2 dates

Hello, 

I'm pretty new to DAX and I'm trying to solve a problem. 

I need to calculate the sum of Fees from the year to a date


Here is an exemple

Date 1           | Date 2           | Fees

01/2018        | 06/2018        | 5

02/2018        | 03/2018        | 3

03/2018        | 08/2018        | 14

11/2017        | 06/2019        | 21

If I pick Date 1 = 03/2018 & Date 2 = 06/2018 my result should be 8 

If I pick Date 1 = 03/2018 & Date 2 = 08/2018 my result should be 22

If I pick Date 1 = 12/2017 & Date 2 = 06/2018 my result should be 21 

 

I used this formula : 

Fees = 
    CALCULATE(
        SUM('Fraisdesante-20190926'[frais_base]);
            FILTER( 
                ALL('Fraisdesante-20190926'[monthid_soins_date]);
                    'Fraisdesante-20190926'[monthid_soins_date] <= MAX('Fraisdesante-20190926'[monthid_soins_date]) 
                );
             FILTER(
                ALL('Fraisdesante-20190926'[monthid_soins_date]);
                    YEAR('Fraisdesante-20190926'[monthid_soins_date]) = YEAR(MAX('Fraisdesante-20190926'[monthid_soins_date]))
               );
            FILTER( 
                ALL('Fraisdesante-20190926'[monthid_compt_date]);
                'Fraisdesante-20190926'[monthid_compt_date] <= MAX('Fraisdesante-20190926'[monthid_compt_date]) 
                );
            FILTER(
                ALL('Fraisdesante-20190926'[monthid_compt_date]);
                YEAR('Fraisdesante-20190926'[monthid_compt_date]) = YEAR(MAX('Fraisdesante-20190926'[monthid_compt_date]))))

But when I pick the case : Date 1 = 12/2017 & Date 2 = 06/2018 

the result is <Blanck> 

 

Thanks in advance

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

@Anonymous 

 

You may drag [Date] from a separate calendar table and apply virtual relationship in DAX measure.

Community Support Team _ Sam Zha
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

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Anonymous 

 

You may drag [Date] from a separate calendar table and apply virtual relationship in DAX measure.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.