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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Table Totals Manipulation

Hi there

I was wondering if any of you can please assist with the query below.

 

I have calculated a measure that is giving me correct values for months; however, I would like to amend the DAX Formula so the total shows the calculated value for the last month.

 

Scenario:

 

02. Month-YearFYEO
(Incorrect Total)
FYEO
(Goal)
Jul-21             29,856,591             29,856,591
Aug-21             30,873,993             30,873,993
Sep-21             30,469,306             30,469,306
Oct-21             30,899,305             30,899,305
Total           144,196,758             30,899,305

 

Noting that other calculated measures are part of the example below, I would like to use a combination of VAR and SUMMARIZE (table manipulation) to arrive to the goal

 

 

FYEO (Incorrect Total) = 
 
VAR MonthstoEOFY = 
    CALCULATE( MEDIAN ( DATES[02. FY Periods Remaining] ) ,
        KEEPFILTERS ( VALUES ( 'DATES'[Date] ) ) )

VAR MonthlyFYEO = 
    [YTD Actual] + ( [YTD Actual Monthly Average] * MonthstoEOFY ) 

VAR TotalFYEO = SUMMARIZE ( DATES , DATES[02. Offset - CurMonth] , "Month Total" , MonthlyFYEO )

RETURN
IF( HASONEVALUE ( DATES[02. Offset - CurMonth] ) , 
    MonthlyFYEO, 
        SUMX ( TotalFYEO, [Month Total] ) )

 

 

I believe I need to change the last part of the formula SUMX ( TotalFYEO, [Month Total] ) so it references the "Month Total" for the last month but unsure of which formula work best.

 

I feel I'm getting close 😅

 

Any ideas would be greatly appreciated.

 

Cheers

 

  

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this:

FYEO (Incorrect Total) =
VAR MonthstoEOFY =
    CALCULATE (
        MEDIAN ( DATES[02. FY Periods Remaining] ),
        KEEPFILTERS ( VALUES ( 'DATES'[Date] ) )
    )
VAR MonthlyFYEO = [YTD Actual] + ( [YTD Actual Monthly Average] * MonthstoEOFY )
VAR TotalFYEO =
    SUMMARIZE ( DATES, DATES[02. Offset - CurMonth], "Month Total", MonthlyFYEO )
RETURN
    IF (
        HASONEVALUE ( DATES[02. Offset - CurMonth] ),
        MonthlyFYEO,
        CALCULATE (
            MonthlyFYEO,
            FILTER ( ALL ( DATES ), DATES[02. Offset - CurMonth] = "Oct-21" )
        )
    )

 

If the values in DATES[02. Offset - CurMonth] column are in Date format then you can change the last row of the above code to:

FILTER ( ALL ( DATES ), DATES[02. Offset - CurMonth] = MAX(DATES[02. Offset - CurMonth] ))

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this:

FYEO (Incorrect Total) =
VAR MonthstoEOFY =
    CALCULATE (
        MEDIAN ( DATES[02. FY Periods Remaining] ),
        KEEPFILTERS ( VALUES ( 'DATES'[Date] ) )
    )
VAR MonthlyFYEO = [YTD Actual] + ( [YTD Actual Monthly Average] * MonthstoEOFY )
VAR TotalFYEO =
    SUMMARIZE ( DATES, DATES[02. Offset - CurMonth], "Month Total", MonthlyFYEO )
RETURN
    IF (
        HASONEVALUE ( DATES[02. Offset - CurMonth] ),
        MonthlyFYEO,
        CALCULATE (
            MonthlyFYEO,
            FILTER ( ALL ( DATES ), DATES[02. Offset - CurMonth] = "Oct-21" )
        )
    )

 

If the values in DATES[02. Offset - CurMonth] column are in Date format then you can change the last row of the above code to:

FILTER ( ALL ( DATES ), DATES[02. Offset - CurMonth] = MAX(DATES[02. Offset - CurMonth] ))

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to simplify it like below.

Please check the below picture and the attached pbix file.

 

Picture2.png

Result: =
VAR monthlymeasure =
SUM ( Data[FYEO] )
VAR totalmeasure =
CALCULATE ( SUM ( Data[FYEO] ), Data[Month-Year] = "Oct-21" )
RETURN
IF ( HASONEVALUE ( Data[Month-Year] ), monthlymeasure, totalmeasure )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Thank you Jihwan, but not quite.

The FYEO is not a column with data but a calculated measure in itself.

I'm confident the monthly values are correct and I would like to keep the formula as it is but adjusting the total to show the value of the last month.

Thank you for your help.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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