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
priyanath1988
Helper III
Helper III

create a table which contains value for last 13 months from the given date

Hi, I am seeking help in created a calculated table whoch contains value for last 13 months.

this is the formula I am using but it is not filtering the rows

BS_Details_Last13Months = CALCULATETABLE(GL_DETAIL, FILTER(GL_DETAIL,GL_DETAIL[ENTRY_DATE] >= DATEADD(GL_DETAIL[previous_month], -13, month)))
 
Note: 
previous_month = EOMONTH(DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())),0)  --> basically I have to calculate last 13 months from the previous month ofthe current date. for example if i run this query today which is march. then in the previous month the value should be last date of Feb.
1 ACCEPTED SOLUTION

Hi @priyanath1988 ,

 

If you want to calculate the value for last 13 months from the given date, I suggest you to try below code.

BS_Details_Last13Months =
VAR _LAST13MONTH =
    EOMONTH ( MAX ( GL_DETAIL[previous_month] ), -13 )
RETURN
    CALCULATETABLE (
        GL_DETAIL,
        FILTER (
            GL_DETAIL,
            GL_DETAIL[ENTRY_DATE] >= _LAST13MONTH
                && GL_DETAIL[ENTRY_DATE] <= MAX ( GL_DETAIL[previous_month] )
        )
    )

My Sample:

vrzhoumsft_1-1679989641954.png

Result is as below.

vrzhoumsft_0-1679989603330.png 

 

Best Regards,
Rico Zhou

 

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
andhiii079845
Super User
Super User

Where is now your problem 🙂





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

Proud to be a Super User!




@andhiii079845 it is not filtering. it is still showing older rows.

Hi @priyanath1988 ,

 

If you want to calculate the value for last 13 months from the given date, I suggest you to try below code.

BS_Details_Last13Months =
VAR _LAST13MONTH =
    EOMONTH ( MAX ( GL_DETAIL[previous_month] ), -13 )
RETURN
    CALCULATETABLE (
        GL_DETAIL,
        FILTER (
            GL_DETAIL,
            GL_DETAIL[ENTRY_DATE] >= _LAST13MONTH
                && GL_DETAIL[ENTRY_DATE] <= MAX ( GL_DETAIL[previous_month] )
        )
    )

My Sample:

vrzhoumsft_1-1679989641954.png

Result is as below.

vrzhoumsft_0-1679989603330.png 

 

Best Regards,
Rico Zhou

 

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.