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

Column that will return payments made 2 months earlier

Hi,

 

I'm trying to improve my column, to eliminate necessity of using statement with actual date: "DATE(2020;04;01)"; because every month I have to change it. 

 

Input data will be always downloaded for last 3 months; and this column is to return values for current mont -2. 

 

Any idea how to do it?

 

Payments Received in April = IF('All'[Document type]="DZ";IF(AND('All'[Document Date]>=DATE(2020;04;01);'All'[Document Date]<DATE(2020;05;01));'All'[Amount in local currency];BLANK());BLANK())

2 ACCEPTED SOLUTIONS

HI @Anonymous ,

 

 

Try this then

 

Payments Received =
VAR a =
    MONTH (
        TODAY ()
    )
VAR b =
    SWITCH (
        TRUE ();
        a = 3; 12;
        a = 2; 11;
        a = 1; 10;
        a
    )
RETURN
    IF (
        'All'[Document type] = "DZ";
        IF (
            AND (
                'All'[Document Date]
                    >= DATE ( 2020; b - 3; 01 );
                'All'[Document Date]
                    < DATE ( 2020; b - 2; 01 )
            );
            'All'[Amount in local currency];
            BLANK ()
        );
        BLANK ()
    )

 

Regards,

Harsh Nathani

 

 

View solution in original post

Anonymous
Not applicable

@harshnathani 

 

Well actually I found this function to work better:

 

Sum of payments CM -2 = 
IF (
    'All'[Document type] = "DZ",
    IF (
        'All'[Document Date] > EOMONTH ( TODAY (), -3 )
            && 'All'[Document Date] <= EOMONTH ( TODAY (), -2 ),
        'All'[Amount in local currency],
        BLANK ()
    ),
    BLANK ()
)

 

 

Thank you. 

 

B.R.

 

M.R. 

View solution in original post

5 REPLIES 5
harshnathani
Community Champion
Community Champion

HI @Anonymous ,

 

You can try this

 

Payments Received in April =
IF (
    'All'[Document type] = "DZ";
    IF (
        AND (
            'All'[Document Date]
                >= TODAY () - 90;
            'All'[Document Date]
                < TODAY () - 60
        );
        'All'[Amount in local currency];
        BLANK ()
    );
    BLANK ()
)

 

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

Hi @harshnathani 

 

Thank you for reply. 


Unfortunately, even if updated in the middle of the month, it must return only values from a single month. 

 

Thank you for your time. 

 

B.R. 
M.R.

HI @Anonymous ,

 

 

Try this then

 

Payments Received =
VAR a =
    MONTH (
        TODAY ()
    )
VAR b =
    SWITCH (
        TRUE ();
        a = 3; 12;
        a = 2; 11;
        a = 1; 10;
        a
    )
RETURN
    IF (
        'All'[Document type] = "DZ";
        IF (
            AND (
                'All'[Document Date]
                    >= DATE ( 2020; b - 3; 01 );
                'All'[Document Date]
                    < DATE ( 2020; b - 2; 01 )
            );
            'All'[Amount in local currency];
            BLANK ()
        );
        BLANK ()
    )

 

Regards,

Harsh Nathani

 

 

Anonymous
Not applicable

@harshnathani Thank you very much. 

 

B.R.

 

M.R.

Anonymous
Not applicable

@harshnathani 

 

Well actually I found this function to work better:

 

Sum of payments CM -2 = 
IF (
    'All'[Document type] = "DZ",
    IF (
        'All'[Document Date] > EOMONTH ( TODAY (), -3 )
            && 'All'[Document Date] <= EOMONTH ( TODAY (), -2 ),
        'All'[Amount in local currency],
        BLANK ()
    ),
    BLANK ()
)

 

 

Thank you. 

 

B.R.

 

M.R. 

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.