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

Urgent - Line Chart for 6 months (May-Oct)

Dear Community members,

 

I am trying to show the trend for the next 6 months (including the current month). For example, if the current month is May, the x-axis should show May-Oct, if the current month is June, the x-axis should show June-Nov and so on.

 

There can be a possibility, that one of the months might not have any data, still that month should be displayed on the x-axis. I tried multiple ways but no luck so far.

 

Help would be appreciated.

 

Thank You!

 

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

Hi @Anonymous 

Create a measure

Measure =
VAR m =
    CALCULATE (
        SUM ( 'Table'[sales] ),
        FILTER (
            'date',
            'date'[Date]
                >= EOMONTH (
                    TODAY (),
                    -1
                ) + 1
                && DATEDIFF (
                    'date'[Date],
                    EOMONTH (
                        TODAY (),
                        -1
                    ) + 1,
                    MONTH
                ) <= 6
        )
    )
RETURN
    IF (
        MAX ( 'date'[Date] )
            >= EOMONTH (
                TODAY (),
                -1
            ) + 1
            && MAX ( 'date'[Date] )
                <= EOMONTH (
                    TODAY (),
                    5
                ),
        m + 0
    )

Capture9.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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

7 REPLIES 7
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a measure

Measure =
VAR m =
    CALCULATE (
        SUM ( 'Table'[sales] ),
        FILTER (
            'date',
            'date'[Date]
                >= EOMONTH (
                    TODAY (),
                    -1
                ) + 1
                && DATEDIFF (
                    'date'[Date],
                    EOMONTH (
                        TODAY (),
                        -1
                    ) + 1,
                    MONTH
                ) <= 6
        )
    )
RETURN
    IF (
        MAX ( 'date'[Date] )
            >= EOMONTH (
                TODAY (),
                -1
            ) + 1
            && MAX ( 'date'[Date] )
                <= EOMONTH (
                    TODAY (),
                    5
                ),
        m + 0
    )

Capture9.JPG

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

mihart
Employee
Employee

Hi @Anonymous 

You can choose to "show items with no data"

nodata.png

 

HTH,

Michele

Anonymous
Not applicable

@mihart Thanks for the reply. But if I enable "Show items with no data" then it shows all the other months as well I want only 6 months to be displayed.

Hi @Anonymous 

Here is a link to an article on quick measures.  

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-quick-measures

 

In that article you'll find instructions for creating 'last 6 months'

 

Take care,

Michele

Anonymous
Not applicable

Hi, @mihart  I need to show future 5 months (including the current month so, in total 6 months) I tried relative date filter, tried creating a new date table, but nothing seems to work.

Checked the URL you provided, and tried with time IntelliSense functions, but doesn't display what I require to show. It shows total of the last 6 months.

 

Thank you!

parry2k
Super User
Super User

@Anonymous I'm sure it is possible using Time INtelligence function, can you share sample dataset and expected output, and will get back to you. There are may TI functions, Next Month, Next Quarter, Next Year etc and those will come handy to solve this.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k Thanks for your reply. Following is the actual VS expected output. The data is different in both, but in the 1st graph (actual), there is no data for August, but the line graph is not indicating 0 there. Below is some sample data as well.

 

 

Capture.PNGCapture1.PNG

 
 
DataDateCount
a29-06-2020 18:3014
a23-09-2020 18:30-2.2
a30-10-2020 18:30-2.2
b21-07-2020 00:0011.5
b20-10-2020 18:3011.9
c20-10-2020 18:3030
d09-11-2020 18:3012

 

Thank You!

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.