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

Two line graph across a non-standard year

Hi all,

 

Complete Power BI newbie here.  I'm trying to create a line graph that shows cumulative values for two years as separate lines.  From previous help topics and a bit of messing around, I've created the following measure:

 

Cumulative value = 
IF(
    MIN( Dates[Date] )
        <= CALCULATE( MAX( Dates[Date] ), ALL( Data )),
    CALCULATE(
        SUM( Data[Values] ),
        FILTER( ALL( Dates ),
            Dates[Date] <= MAX( Dates[Date] ) && YEAR( Dates[Date] ) = YEAR( MAX( Dates[Date] ))
        )
    )
)

Which almost works, except that I'm not looking for a graph that runs from January - December.  My resulting graph  is this:

(Axis: Month - Legend: Year - Values: The above calculated field)  

 

Graph.png

 

 

 

 

 

 

 

 

 

So to my question -  Is there an easy way to replicate the functionality of the filter in the above measure in a way that respects the custom month order in my date table? Basically, I'm looking to have the "reset point" be August, rather than December.

 

Thanks in advance for any help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @v-shex-msft,

 

Thanks for getting back to me.  Your comment, plus a good night's sleep and my morning coffee, helped me realise that the answer was more simple than I was thinking.

 

I already had a custom sort for month which was working perfectly, I just needed to add a custom "year order" column and refer to that directly rather than using YEAR.

 

Cumulative value = 
IF(
    MIN( Dates[Date] )
        <= CALCULATE( MAX( Dates[Date] ), ALL( Data )),
    CALCULATE(
        SUM( Data[Values] ),
        FILTER( ALL( Dates ),
            Dates[Date] <= MAX( Dates[Date] ) && YEAR( Dates[Date] ) = YEAR( MAX( Dates[Date] ))
            Dates[Date] <= MAX( Dates[Date] ) && Dates[Year Order] = MAX( Dates[Year Order] )
        )
    )
)

Results in the graph changing to :

Graph2.png

 

 

 

 

 

 

 

 

 

Thanks for your assistance!

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

>>Is there an easy way to replicate the functionality of the filter in the above measure in a way that respects the custom month order in my date table? 

In fact, measure is impossible to effect axis sorting order.

In my opinion, I'd like to suggest you to modify 'sort by column' of month field or add a custom sort order table for this scenario.

Sort by column in Power BI Desktop

Custom Sorting in Power BI

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hi @v-shex-msft,

 

Thanks for getting back to me.  Your comment, plus a good night's sleep and my morning coffee, helped me realise that the answer was more simple than I was thinking.

 

I already had a custom sort for month which was working perfectly, I just needed to add a custom "year order" column and refer to that directly rather than using YEAR.

 

Cumulative value = 
IF(
    MIN( Dates[Date] )
        <= CALCULATE( MAX( Dates[Date] ), ALL( Data )),
    CALCULATE(
        SUM( Data[Values] ),
        FILTER( ALL( Dates ),
            Dates[Date] <= MAX( Dates[Date] ) && YEAR( Dates[Date] ) = YEAR( MAX( Dates[Date] ))
            Dates[Date] <= MAX( Dates[Date] ) && Dates[Year Order] = MAX( Dates[Year Order] )
        )
    )
)

Results in the graph changing to :

Graph2.png

 

 

 

 

 

 

 

 

 

Thanks for your assistance!

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.