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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
charbaugh
Helper I
Helper I

Fiscal YTD through Last Month

I have a measure that was working until we rolled into 2023.  The desired output is fiscal YTD sales through the prior month.  For example, we are in January now, so the output would show Fiscal YTD thorugh the end of December.

 

Here is the formula I'm using:

Sales YTD Last Month =
CALCULATE(SUM(
    'All Sales'[Amount]),
    DATESYTD('REF Dates'[Date], "9/30"),
    MONTH('REF Dates'[Date]) < MONTH(TODAY())
)
 
Prior to Jan1, it gave the desired results.  Now it gives no results.  I should note that I have tried replacing the [Date] field about with the [Fiscal Date Ref] and still did not receive an output.
 
 
REF Dates is a date table:
 
charbaugh_0-1674838394954.png

 

 All Sales is my table with sales data:
charbaugh_1-1674838583766.png

 

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

Hi @charbaugh ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

Calendar:

 

Calendar = 
ADDCOLUMNS (
    CALENDAR ( DATE ( 2021, 7, 1 ), DATE ( 2023, 6, 30 ) ),
    "Month-Year", FORMAT ( [Date], "mmm-yyyy" ),
    "Month-Year sort", EOMONTH ( [Date], 0 )
)

 

Sales:

Picture1.png...Picture2.png

(2) We can create a measure.

 

Sales YTD fiscal: = 
VAR _currentmonthend =
    EOMONTH ( MAX ( 'Calendar'[Date] ), 0 )
VAR _currentmonthendinfo =
    MAX ( Sales[Date] )
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[Month-Year] ),
        IF (
            _currentmonthend = _currentmonthendinfo,
            CALCULATE ( SUM(Sales[Sales]), DATESYTD ( 'Calendar'[Date], "9-30" ) )
        ),
        CALCULATE (  SUM(Sales[Sales]), DATESYTD ( 'Calendar'[Date], "9-30" ) )
    )

 

(3) Then the result is as follows.

Picture3.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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
v-tangjie-msft
Community Support
Community Support

Hi @charbaugh ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

Calendar:

 

Calendar = 
ADDCOLUMNS (
    CALENDAR ( DATE ( 2021, 7, 1 ), DATE ( 2023, 6, 30 ) ),
    "Month-Year", FORMAT ( [Date], "mmm-yyyy" ),
    "Month-Year sort", EOMONTH ( [Date], 0 )
)

 

Sales:

Picture1.png...Picture2.png

(2) We can create a measure.

 

Sales YTD fiscal: = 
VAR _currentmonthend =
    EOMONTH ( MAX ( 'Calendar'[Date] ), 0 )
VAR _currentmonthendinfo =
    MAX ( Sales[Date] )
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[Month-Year] ),
        IF (
            _currentmonthend = _currentmonthendinfo,
            CALCULATE ( SUM(Sales[Sales]), DATESYTD ( 'Calendar'[Date], "9-30" ) )
        ),
        CALCULATE (  SUM(Sales[Sales]), DATESYTD ( 'Calendar'[Date], "9-30" ) )
    )

 

(3) Then the result is as follows.

Picture3.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

This appears to give me a good fiscal YTD, all the way up thorugh today.  But what I need is fiscal YTD, up to the end of last fiscal month.  I'm trying to figure out how to build a simplified dataset to share, but this is part of a very large and complex file.  

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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