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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JP08
New Member

How to calculate amount from the filter month and all future month in the filter year?

I have requirement to show sale amount from current filter date and year until the last month of the year.

 

Start DateAmount
01-Jan-20231000
01-Feb-2023500
01-Apr-20232000

 

From the table, the requirement is If I select period Jan-23 report will show

Jan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23Total
100050002000000

3500

 

If I select period Feb-23 report will show

Jan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23Total
0500020000002500

 

Can anyone help use to create measure for this requirement?

 

Regards,

JP

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JP08 ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1686206249404.png

Table2:

vbinbinyumsft_1-1686206279857.png

 

2. cretae a  measure with below dax formula

Measure =
VAR _sd =
    SELECTEDVALUE ( 'Table'[Start Date] )
VAR _a =
    SELECTEDVALUE ( 'Table 2'[Date] )
VAR _val =
    CALCULATE ( MAX ( 'Table'[Amount] ), 'Table'[Start Date] = _a )
VAR _val1 =
    IF ( ISBLANK ( _val ), 0, _val )
VAR _b =
    FILTER ( ALL ( 'Table' ), [Start Date] >= _sd )
RETURN
    IF (
        ISFILTERED ( 'Table 2'[Date] ),
        IF ( _a < _sd, 0, _val1 ),
        SUMX ( _b, [Amount] )
    )

 

3. add a slicer with Table field, add a matrix with Table2 field and measure

Animation04.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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
Anonymous
Not applicable

Hi @JP08 ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1686206249404.png

Table2:

vbinbinyumsft_1-1686206279857.png

 

2. cretae a  measure with below dax formula

Measure =
VAR _sd =
    SELECTEDVALUE ( 'Table'[Start Date] )
VAR _a =
    SELECTEDVALUE ( 'Table 2'[Date] )
VAR _val =
    CALCULATE ( MAX ( 'Table'[Amount] ), 'Table'[Start Date] = _a )
VAR _val1 =
    IF ( ISBLANK ( _val ), 0, _val )
VAR _b =
    FILTER ( ALL ( 'Table' ), [Start Date] >= _sd )
RETURN
    IF (
        ISFILTERED ( 'Table 2'[Date] ),
        IF ( _a < _sd, 0, _val1 ),
        SUMX ( _b, [Amount] )
    )

 

3. add a slicer with Table field, add a matrix with Table2 field and measure

Animation04.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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