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

Last 6 months data

I need to display last 6 months from the fiscal month column ignoring the current month (data type is text-FY22JAN) .The fiscal month totally containing 18 months and i need to display only last six months. and also the date table is not the hirarchey one. how i need to write DAX expression for this. Please help me out anyone immediately.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi, actually i have calendar date column . so i have solved this without writing any measure using PBI only. 

 

i have dragged calendar date column in filters on page then , in last 6 month i have selected and then i selected calendar months means only completed months. so it will give only last six months of of fiscal month column even if the year changes later.

 

karlapudis_0-1656336936651.png

 

View solution in original post

Hi @Anonymous,

 

That’s great! Thanks for your reply!

 

Could you please mark the solution by Accept it as the solution to help other members find it more quickly. Thanks in advance!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous,

 

Not sure how your model looks like. If you don’t have a calendar table, you may try this solution.

Create a Measure as follows. It will help you filter out the last six months.

 

LastSixMonths =
VAR year_ =
    2000 + LEFT ( RIGHT ( MAX ( 'Fiscal Month'[fiscal month] ), 5 ), 2 )
VAR month_ =
    RIGHT ( MAX ( 'Fiscal Month'[fiscal month] ), 3 )
VAR month_no =
    SWITCH (
        month_,
        "Jan", 1,
        "Feb", 2,
        "Mar", 3,
        "Apr", 4,
        "May", 5,
        "Jun", 6,
        "Jul", 7,
        "Aug", 8,
        "Sep", 9,
        "Oct", 10,
        "Nov", 11,
        "Dec", 12
    )
VAR fiscalDate =
    DATE ( year_, month_no, 1 )
VAR firstDay =
    DATE ( year_, month_no, 1 )
VAR currentTime =
    TODAY ()
VAR currentYear =
    YEAR ( currentTime )
VAR currentMonth =
    MONTH ( currentTime )
VAR lastSixMonOfCur = 12 - ( 6 - currentMonth )
VAR MinDate =
    IF (
        lastSixMonOfCur >= 6,
        DATE ( currentYear - 1, lastSixMonOfCur, 1 ),
        DATE ( currentYear, lastSixMonOfCur, 1 )
    )
RETURN
    IF (
        fiscalDate >= MinDate
            && fiscalDate < DATE ( currentYear, currentMonth, 1 ),
        1,
        0
    )

 

 

After that, you could calculated based on it or just filter visual data by dragging it to Filters pane.

vcazhengmsft_0-1656298729830.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Anonymous
Not applicable

Hi, actually i have calendar date column . so i have solved this without writing any measure using PBI only. 

 

i have dragged calendar date column in filters on page then , in last 6 month i have selected and then i selected calendar months means only completed months. so it will give only last six months of of fiscal month column even if the year changes later.

 

karlapudis_0-1656336936651.png

 

Hi @Anonymous,

 

That’s great! Thanks for your reply!

 

Could you please mark the solution by Accept it as the solution to help other members find it more quickly. Thanks in advance!

 

Best Regards,

Community Support Team _ Caiyun

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.