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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Fantmas
Helper III
Helper III

DAX use value of the month as value for December

Hello everyone,

I have a pourcentage that display the ratio at the last period available (May), I need to use this value as value for end of the year (december)

I create a measure using dax to replace the blank by the value I want but it do not returns me the value for december

Fantmas_0-1686226566913.png


How can I have the value of May 23 as Dec 23,

Below the dax code, thank you for your support

%  Evolution  = 

VAR Closing = LASTDATE(ALL('DimDate Closing Period'[Date]))

VAR Max_Period = YEAR(LASTDATE(ALL('DimDate Closing Period'[Date])))+2

VAR Current_Year = YEAR(LASTDATE(ALL('DimDate Closing Period'[Date])))

VAR End_Year =

CALCULATE( [% Female M & Above],
    FILTER (
        'DimDate',
        MONTH ( 'DimDate'[Date]) = 12
        && YEAR ( 'DimDate'[Date] ) >= Current_Year - 3 && YEAR('DimDate'[Date]) <= Max_Period)
)

VAR Last_Value =

CALCULATE( 
    [% Value],
    FILTER ('DimDate Closing Period',
        'DimDate Closing Period'[Date] = Closing)
)

RETURN

SWITCH(TRUE(),
    NOT ISBLANK(End_Year), End_Year,
    ISBLANK(End_Year), last_Value,
    BLANK()
)




 

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

Hi @Fantmas ,

 

It seems that you want to show the last rate in each year as Dec month value. I suggest you to create a dimdate table with continuous date to help calculation.

Sample:

vrzhoumsft_1-1686641127618.png

vrzhoumsft_2-1686641136405.png

Measure:

Measure = 
VAR _LastDateEachYear =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALL ( 'Table' ),
            YEAR ( 'Table'[Date] ) = YEAR ( MAX ( 'Calendar'[Date] ) )
        )
    )
VAR _RATE =
    CALCULATE (
        SUM ( 'Table'[Rate] ),
        FILTER (
            ALL ( 'Table' ),
            YEAR ( 'Table'[Date] ) = MAX ( 'Calendar'[Year] )
                && 'Table'[Date] = _LastDateEachYear
        )
    )
RETURN
    IF ( MAX ( 'Calendar'[Month] ) = 12, _RATE )

Result is as below.

vrzhoumsft_0-1686641100224.png

Best Regards,
Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @Fantmas ,

 

It seems that you want to show the last rate in each year as Dec month value. I suggest you to create a dimdate table with continuous date to help calculation.

Sample:

vrzhoumsft_1-1686641127618.png

vrzhoumsft_2-1686641136405.png

Measure:

Measure = 
VAR _LastDateEachYear =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALL ( 'Table' ),
            YEAR ( 'Table'[Date] ) = YEAR ( MAX ( 'Calendar'[Date] ) )
        )
    )
VAR _RATE =
    CALCULATE (
        SUM ( 'Table'[Rate] ),
        FILTER (
            ALL ( 'Table' ),
            YEAR ( 'Table'[Date] ) = MAX ( 'Calendar'[Year] )
                && 'Table'[Date] = _LastDateEachYear
        )
    )
RETURN
    IF ( MAX ( 'Calendar'[Month] ) = 12, _RATE )

Result is as below.

vrzhoumsft_0-1686641100224.png

Best Regards,
Rico Zhou

 

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

lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.