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
Syndicate_Admin
Administrator
Administrator

Last 5 years

Hello! I need if you can help me with the measure "% last 5" where I am trying to get the average percentage of the last accounting years, (Ejcontable column), the measure I use is as follows:

% last 5 =
Where _max = Max(data[EjContable])
Where _min =_max-4
RETURN
CALCULATE([_participacion],FILTER(all(data),data[EjContable]>=_min && data[EjContable]<=_max), REMOVEFILTERS(data[EjContable]))
But the value that returns me is 1 osea 100% when it should be another value.
Screenshot_1.png

Example if filter by id 37 should give me a value of 17,36%. because if I add a filter of accounting exercises and choose the last 5 the value it gives me is 17.36% but instead it always gives me 100%.

Screenshot_2.pngScreenshot_1.png

Can you help me? Thank you.

Attached pbi.

Best regards.

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

Hi @Syndicate_Admin ,

In the EjContable column of other IDs, are there also these numbers 52, 53, 54, 55, 56? If so, tweak your formula to:

% last 5 =
VAR _max =
    MAX ( data[EjContable] )
VAR _min = _max - 4
RETURN
    CALCULATE (
        [_participacion],
        FILTER (
            ALLSELECTED ( data ),
            data[EjContable] >= _min
                && data[EjContable] <= _max
        ),
        REMOVEFILTERS ( data[EjContable] )
    )

In your formula, the ALL function take all ID into consideration, replace it to ALLSELECTED to try.

 

Best Regards,
Community Support Team _ kalyj

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

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

Is your problem solved? If so, would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirment will find the solution quickly and benefit here, thank you!

Best Regards,
Community Support Team _ kalyj

v-yanjiang-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

In the EjContable column of other IDs, are there also these numbers 52, 53, 54, 55, 56? If so, tweak your formula to:

% last 5 =
VAR _max =
    MAX ( data[EjContable] )
VAR _min = _max - 4
RETURN
    CALCULATE (
        [_participacion],
        FILTER (
            ALLSELECTED ( data ),
            data[EjContable] >= _min
                && data[EjContable] <= _max
        ),
        REMOVEFILTERS ( data[EjContable] )
    )

In your formula, the ALL function take all ID into consideration, replace it to ALLSELECTED to try.

 

Best Regards,
Community Support Team _ kalyj

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

Syndicate_Admin
Administrator
Administrator

As I can not attach the pbi I add more information

_participacion = DIVIDE([Tn Client],[Tn Exercise])
Tn Client = CALCULATE(SUM(date[TON])
Tn Exercise = CALCULATE (SUM(date[TON]),REMOVEFILTERS(data[Id]))
Thank you.
Syndicate_Admin
Administrator
Administrator

How can I attach the pbix? It won't let me. Thank you.

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.