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
ElliotP
Post Prodigy
Post Prodigy

Final Value of Month

Afternoon,

 

I'm trying to calculate the percentage change between two concurrent months for example; I'm comfortable with the overall setup of that, but I'm not sure how to only do it for the final value of the month for the respective months.

 

I've tried EODMonth, LastDate, etc but I'm not sure how to only pull the final date of each month.

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

here you will find a pbix file that contains a little example to answer your question.

 

Please be ware that the solution also relies on a Calendar table, related to the fact table. Besides the Date, Year-Month, and Year column, this table also contains a column that numbers the Months meaning that all days of the first month are marked with 1.

 

All the measures contained defined in the Calendar table are not necessary for the final calculation.

 

The fact table contains two measures: "growth MoM Latest Value" and "Final growth MoM Latest Value" the first one calculates everything in one go, whereas the 2nd one uses the interemediate measures "ms ... curr Month" and "ms ... prev Month".

Here is a litte screenshot that shows the base data

image.png

 

and here is a screenshot from a table that also contains all the measures

image.png

 

And here is one of the measures

growth MoM Latest Value = 
var factcurrentRunningMonth = MAX('Calendar'[runnning Month])
var factLatestDateCurrentMonth = 
    CALCULATE(
        MAX('simple fact'[Date])
        ,FILTER(
            ALL('Calendar')
            ,'Calendar'[runnning Month] = factcurrentRunningMonth
        )
    )
var factLatestDatePrevMonth = 
    CALCULATE(
        MAX('simple fact'[Date])
        ,FILTER(
            ALL('Calendar')
            ,'Calendar'[runnning Month] = factcurrentRunningMonth -1
        )
    )
var latestvalueCurrMonth =
CALCULATE(
    SUM('simple fact'[Amount])
    ,FILTER(
        ALL('Calendar')
        ,'Calendar'[Date] =  factLatestDateCurrentMonth
    )
)
var latestvaluePrevMonth =
CALCULATE(
    SUM('simple fact'[Amount])
    ,FILTER(
        ALL('Calendar')
        ,'Calendar'[Date] = factLatestDatePrevMonth
    )
)
return
DIVIDE(latestvalueCurrMonth, latestvaluePrevMonth, BLANK())

 

Hope this is what you are looking for

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

4 REPLIES 4
TomMartens
Super User
Super User

Hey,

 

here you will find a pbix file that contains a little example to answer your question.

 

Please be ware that the solution also relies on a Calendar table, related to the fact table. Besides the Date, Year-Month, and Year column, this table also contains a column that numbers the Months meaning that all days of the first month are marked with 1.

 

All the measures contained defined in the Calendar table are not necessary for the final calculation.

 

The fact table contains two measures: "growth MoM Latest Value" and "Final growth MoM Latest Value" the first one calculates everything in one go, whereas the 2nd one uses the interemediate measures "ms ... curr Month" and "ms ... prev Month".

Here is a litte screenshot that shows the base data

image.png

 

and here is a screenshot from a table that also contains all the measures

image.png

 

And here is one of the measures

growth MoM Latest Value = 
var factcurrentRunningMonth = MAX('Calendar'[runnning Month])
var factLatestDateCurrentMonth = 
    CALCULATE(
        MAX('simple fact'[Date])
        ,FILTER(
            ALL('Calendar')
            ,'Calendar'[runnning Month] = factcurrentRunningMonth
        )
    )
var factLatestDatePrevMonth = 
    CALCULATE(
        MAX('simple fact'[Date])
        ,FILTER(
            ALL('Calendar')
            ,'Calendar'[runnning Month] = factcurrentRunningMonth -1
        )
    )
var latestvalueCurrMonth =
CALCULATE(
    SUM('simple fact'[Amount])
    ,FILTER(
        ALL('Calendar')
        ,'Calendar'[Date] =  factLatestDateCurrentMonth
    )
)
var latestvaluePrevMonth =
CALCULATE(
    SUM('simple fact'[Amount])
    ,FILTER(
        ALL('Calendar')
        ,'Calendar'[Date] = factLatestDatePrevMonth
    )
)
return
DIVIDE(latestvalueCurrMonth, latestvaluePrevMonth, BLANK())

 

Hope this is what you are looking for

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
TomMartens
Super User
Super User

Hey,

wondering what you mean by "Final Value of the Month"?

Is this the latest date for a certain measure, eg today would be the 2018-04-04 or
is the final value the aggregated value from 2018-04-01 to 2018-04-04?

How do you want to compare the April value to the March value? Have the same number of days to be considered?

Regards
Tom


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

@TomMartensthanks for the quick repsonse. The latest day of each month.

 

So for example, for Feb 2018 it would be the 28/2. For this month it would be the 4th (Current date for me is the 4/4).

 

The same number of days don't have to be considered, I saw an example on radacad but this should be a little bit nicer.

Hey,

thanks for the clarification, i assume that it would be 27/2 if 28/2 has no value?

Due to traveling my next answer will be delayed 😉

Regards
Tom


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.