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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Myagi-Do
Helper I
Helper I

Same Period Last Month in Line Charts - How to remove non existing days

Hi there,

 

I am tying to create a line chart that shows this month values (sales or whatever) and last month values when the dates of the current selected month are on the x axis.   


I am expecting to see only dates in this chart which have an existing "day" in the previous month. This means data for march should only show days until the 28th since February has only 28 days. 

 

I can get it to work if I use last months dates on the x axis but this creates a confusing hover over meassage.

 

Screenshot 2023-05-31 at 21.56.50.png

 The values are present for non consecutive dates (some dates don't have values) and I am using a Calendar Table with consecutive dates for the filtering.

I tried several SPLM calculations which have the result seen above or use the wrong context in which the total amount is copied for all dates.

Screenshot 2023-05-31 at 22.02.39.png

 

Screenshot 2023-05-31 at 22.04.58.png


I watched videos from @marcorusso and others and I read @Greg_Deckler time intelligence blog post but I still don't get it.

Any ideas are appreciated. Here is a pbix file with the example.


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

Hi @Myagi-Do ,

 

Please try:

Measure_SPLM =
IF (
    DAY ( SELECTEDVALUE ( 'Calendar'[Date] ) )
        = DAY ( EDATE ( SELECTEDVALUE ( 'Calendar'[Date] ), -1 ) ),
    CALCULATE (
        SUM ( same_period[value] ),
        FILTER (
            ALL ( 'Calendar' ),
            [Date] = EDATE ( SELECTEDVALUE ( 'Calendar'[Date] ), -1 )
        )
    )
)

Output:

vjianbolimsft_0-1685675495460.png

Best Regards,

Jianbo 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

2 REPLIES 2
Myagi-Do
Helper I
Helper I

This worked like a charm. I see what you did there with the if statement and I didn't know the EDATE function before. 

Thanks for the help @v-jianboli-msft 


 

 

v-jianboli-msft
Community Support
Community Support

Hi @Myagi-Do ,

 

Please try:

Measure_SPLM =
IF (
    DAY ( SELECTEDVALUE ( 'Calendar'[Date] ) )
        = DAY ( EDATE ( SELECTEDVALUE ( 'Calendar'[Date] ), -1 ) ),
    CALCULATE (
        SUM ( same_period[value] ),
        FILTER (
            ALL ( 'Calendar' ),
            [Date] = EDATE ( SELECTEDVALUE ( 'Calendar'[Date] ), -1 )
        )
    )
)

Output:

vjianbolimsft_0-1685675495460.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.