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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

Data accumulated over several years

Good morning

I have the following problem:

I have created this graph of Orders accumulated over several years using this measure:

Accumulated orders = CALCULATE(SUM('Total Order Entry'[Amount]),DATESYTD('Master Calendar'[Day]))

josefmc08_0-1634891302583.png

What I need is that in the year 2021, when it reaches today, instead of the flat line continuing (because there is no data yet), that the line is cut there and does not continue.

It's possible?. Thank you

Jose

8 REPLIES 8
Anonymous
Not applicable

HI @Anonymous,

According to your description, it sounds like you want to show the line graph continue even if there are no match records with the next time periods? If that is the case, I think the time intelligence function may not suitable for your requirement.
For this scenario, you can use the date function to manually define the filter ranges and change the compare operator to 'less than and equal to' current date(<=) then the line graph will be shown on the following time period even if no records existed.

 

Accumulated orders =
VAR currDate =
    MAX ( 'Master Calendar'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Total Order Entry'[Amount] ),
        FILTER (
            ALLSELECTED ( 'Total Order Entry' ),
            YEAR ( [Date] ) = YEAR ( currDate )
                && [Date] <= currDate
        )
    )

 

Regards,

Xiaoxin Sheng

Hello, thanks for the help but it does not fix the problem.

I have used your measurement:

Accumulated orders =
WHERE currDate =
MAX ( 'Master Calendar'[Day] )
RETURN
CALCULATE (
SUM ( 'Total Order Entry'[Amount] ),
FILTER (
ALLSELECTED ( 'Total Entry Orders' ),
YEAR ( 'Total Entry Orders' [Date Entry (ERDAT)] ) = YEAR ( currDate )
&& 'Total Entry Orders' [Date Entry (ERDAT)] <= currDate
)
)

But the result is the same:

josefmc08_0-1635873882990.png

And what I was looking for is that, since there is still no data from 12/2021, that data should be 0 or empty instead of repeating the same data that there is in 11/2021

Anonymous
Not applicable

Hi @Anonymous,

Perhaps you can try to add an if statement to check the current axis date and max available fact table date and use it as a filter to prevent the calculation on not existing date ranges:

Accumulated orders =
VAR currDate =
    MAX ( 'Master Calendar'[Day] )
VAR maxDate =
    CALCULATE (
        MAX ( 'Total Entry Orders'[Date Entry (ERDAT)] ),
        FILTER (
            ALLSELECTED ( 'Total Entry Orders' ),
            YEAR ( 'Total Entry Orders'[Date Entry (ERDAT)] ) = YEAR ( currDate )
        )
    )
RETURN
    IF (
        currDate <= maxDate,
        CALCULATE (
            SUM ( 'Total Order Entry'[Amount] ),
            FILTER (
                ALLSELECTED ( 'Total Entry Orders' ),
                YEAR ( 'Total Entry Orders'[Date Entry (ERDAT)] ) = YEAR ( currDate )
                    && 'Total Entry Orders'[Date Entry (ERDAT)] <= currDate
            )
        )
    )

Regards,
Xiaoxin Sheng

Dear Sir,

I tried the formula, but it gives an error of: "The end of the entry has been reached":

josefmc08_0-1637600958346.png

Greetings

Jose

Anonymous
Not applicable

Hi @josefmc08,

This issue seems more related to the brackets.

After check the snapshot, I found you add three more ')' at the end of the formula so that power bi cannot recognize and process this expression.

Regards,
Xiaoxin Sheng

Sorry, it doesn't work, it gives error and nothing comes out.

amitchandak
Super User
Super User

@Syndicate_Admin , Create a YTD measure and take the month axis and year on Legend

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Good morning

I'm afraid the solution doesn't work, it's the same:

josefmc08_0-1634894729466.png

What I would need is for future dates not to appear. For example, in the table below the graph, the months of November and December 2021 should come out empty because we have not yet arrived.

Thank you for your help

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.