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
SoniaRadaelli
Regular Visitor

Calculate last FY figures with multiple years

I'm using the following measure to calculate the growth of this fiscal year period (e.g. april to sept)  Vs LY same period but if LFY is 0 the result is not correct as the formula apply the growth respect to another FY

example:

FY2020     sales 100

FY2019     sales  0

FY2018    sales 90

DAX result +11% (100/90-1)

 

Here the measure I'm using:

 

% Vs. LY orig =
VAR first_date =
CALCULATE ( (MIN( sales_totale[anno FY] )), ALL ( sales_totale[anno FY] ) )
VAR date_selection =
CALCULATE (
MAX ( sales_totale[anno FY] ),
FILTER ( ALL ( sales_totale[anno FY] ), ( sales_totale[anno FY] ) < MAX ( sales_totale[anno FY] ) ))
RETURN
IF ( MIN ( sales_totale[anno FY] ) = first_date,
BLANK (),
SUM ( sales_totale[UBLNAM] ) /
CALCULATE ( SUM ( sales_totale[UBLNAM] ),
FILTER ( ALL ( sales_totale[anno FY] ), sales_totale[anno FY] = date_selection ) )-1 )

 

Any Idea?

Thanks

1 ACCEPTED SOLUTION

Hi @SoniaRadaelli ,,

 

Try the following measure below:

% Vs. LYS = 
VAR first_date =
    CALCULATE ( ( MIN ( SALESSHARED[anno FYS] ) ), ALL ( SALESSHARED[anno FYS] ) )
VAR lastdatenonblank =
FILTER(ALL(SALESSHARED[anno FYS]), SALESSHARED[anno FYS] < MAX(SALESSHARED[anno FYS]))
RETURN
    IF (
        MAX ( SALESSHARED[anno FYS] ) = first_date,
        BLANK (),
        DIVIDE (
            SUM ( SALESSHARED[NETTO] ),
            CALCULATE (
                SUM ( SALESSHARED[NETTO] ),
                FILTER (
                    ALL ( SALESSHARED[anno FYS] ),
                    SALESSHARED[anno FYS] = MAXX ( lastdatenonblank, SALESSHARED[anno FYS] )
                )
            )
        ) - 1
    )

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @SoniaRadaelli ,

 

Try the following measure:

 

 

% Vs. LY orig = 

VAR first_date =
CALCULATE ( (MIN( sales_totale[anno FY] )), ALL ( sales_totale[anno FY] ) )
VAR lastdatenonblank =
    FILTER (
        SUMMARIZE (
            ALL ( sales_totale[anno FY], sales_totale[Sales] ),
            sales_totale[anno FY],
            "@sales", SUM ( sales_totale[Sales] )
        ),
        [@sales] > 0
            && sales_totale[anno FY] < MAX ( sales_totale[anno FY] )
    )
RETURN
    IF(MAX(sales_totale[anno FY]) = first_date,
DIVIDE (
        SUM ( sales_totale[Sales] ),
        CALCULATE (
            SUM ( sales_totale[Sales] ),
            FILTER (
                ALL ( sales_totale[anno FY] ),
                sales_totale[anno FY] = MAXX ( lastdatenonblank, sales_totale[anno FY] )
            )
        )
    ) - 1)

 

 

In your case since you were making only the selewction of the values below the max year selection the value you returned was 2019 value and not 2018.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

here the result using your dax

SoniaRadaelli_0-1632990671503.png

 

🤔

 

modifying your if statement, adding the underlined part:

IF(MAX(sales_totale[anno FY]) = first_date,
BLANK(),
DIVIDE (
SUM ( sales_totale[UBLNAM] ),
CALCULATE (
SUM ( sales_totale[UBLNAM] ),
FILTER (
ALL ( sales_totale[anno FY] ),
sales_totale[anno FY] = MAXX ( lastdatenonblank, sales_totale[anno FY] )
)
)
) - 1)

I have the following result

 

SoniaRadaelli_1-1632991872450.png

 

as you can see in FY2020 the % is calculated respect to FY2018 and not on FY2019

 

Hi @SoniaRadaelli ,,

 

Try the following measure below:

% Vs. LYS = 
VAR first_date =
    CALCULATE ( ( MIN ( SALESSHARED[anno FYS] ) ), ALL ( SALESSHARED[anno FYS] ) )
VAR lastdatenonblank =
FILTER(ALL(SALESSHARED[anno FYS]), SALESSHARED[anno FYS] < MAX(SALESSHARED[anno FYS]))
RETURN
    IF (
        MAX ( SALESSHARED[anno FYS] ) = first_date,
        BLANK (),
        DIVIDE (
            SUM ( SALESSHARED[NETTO] ),
            CALCULATE (
                SUM ( SALESSHARED[NETTO] ),
                FILTER (
                    ALL ( SALESSHARED[anno FYS] ),
                    SALESSHARED[anno FYS] = MAXX ( lastdatenonblank, SALESSHARED[anno FYS] )
                )
            )
        ) - 1
    )

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @SoniaRadaelli 

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.