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
GhadaMehrez
Helper III
Helper III

add filter to measure formula

Please I need support here I have measure calculating percentage of {Total estimated cost} per each strategy category 

 

but now I need to add filter to the measure to give me the percentage also based on period (Short Term- Mid Term- Long Term)

 

 

 

% ETC V3 = 
DIVIDE(
    [ETC This Year],
    CALCULATE(
        [ETC This Year],
        ALL('Projects'[fls_StrategyThemeName])
    ) 
)

 

 

 

I created another measure calculating N0. of months between start and end date of projects so I can get the period.

 

 

 

No.of months = SUMX(Projects, DATEDIFF(Projects[fls_actualstartdate],Projects[fls_actualenddate],month))

 

 

 

 

 

I tried to add this filter to the measure, for the product development I, but it gives wrong percentage:

 

 

 

% ETC V3 = 
DIVIDE(
    [ETC This Year],
    CALCULATE(
        [ETC This Year],
        ALL('Projects'[fls_StrategyThemeName]),FILTER(Projects, [No.of months] <=12)
    ) 
)

 

 

 

GhadaMehrez_0-1660211114196.png

GhadaMehrez_0-1660211695521.png

 

 

9 REPLIES 9
v-chenwuz-msft
Community Support
Community Support

Hi @GhadaMehrez ,

 

Please try this:

% ETC V3 =
DIVIDE (
    [ETC This Year],
    CALCULATE (
        [ETC This Year],
        FILTER ( ALLSELECTED ( Projects ), [No.of months] <= 12 )
    )
)

 

Best Regards

Community Support Team _ chenwu zhu

 

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

@v-chenwuz-msft  Thanks for your support,

 

But the output of the measure is wrong it gives me 132% as the screen below:

GhadaMehrez_0-1660726792599.png

 

I tried to update the measure to rely on another measure {Duration Flag}

but it gives error could you support :

 

% AB = DIVIDE ( [ETC This Year], CALCULATE ( [ETC This Year], FILTER ( ALLSELECTED ( Projects ), [Duration Flag] Short Term ) ) )
GhadaMehrez_1-1660726918547.png

 

Hi @GhadaMehrez ,

 

This:

%AB =
VAR _all =
    CALCULATE (
        [ETC This Year],
        FILTER ( ALLSELECTED ( Projects ), [no.month] <= 12 )
    )
VAR _s =
    SUMMARIZE (
        Projects,
        [fls_strategythemename],
        [pum_name],
        "etc", [etc this year],
        "ab", DIVIDE ( [etc this year], _all )
    )
RETURN
    SUMX ( _s, [ab] )

 

Best Regards

Community Support Team _ chenwu zhu

 

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

thanks a lot for your support but still the output not correct it give me above 100% 

I'm attaching link of simplified PBI i hope if you can access it and help.

 

Thanks in advance.

https://drive.google.com/file/d/1emP0cQwYm9OHvqQrveVkwR69AH5TzG1S/view?usp=sharing

 

amitchandak
Super User
Super User

@GhadaMehrez , Try like

 

% ETC V3 =
DIVIDE(
[ETC This Year],
CALCULATE(
Sumx(FILTER(Projects, [No.of months] <=12),[ETC This Year]),
ALL('Projects'[fls_StrategyThemeName]),
)
)

 

 

or

 

% ETC V3 =
DIVIDE(
Sumx(FILTER(Projects, [No.of months] <=12),[ETC This Year]),
CALCULATE(
Sumx(FILTER(Projects, [No.of months] <=12),[ETC This Year]),
ALL('Projects'[fls_StrategyThemeName]),
)
)

Hi @amitchandak , I tried to change a little in the expression to rely directly on the Actual Start and end dates not on the measure (No. Month) but still not working any idea how to fulfill this need please 

 

 

% AC = 
DIVIDE(
[ETC This Year],
CALCULATE(
Sumx(FILTER(Projects, DATEDIFF(Projects[fls_actualstartdate],Projects[fls_actualenddate],MONTH <=12, ALL(Projects[fls_StrategyThemeName])
))

 

 

 

GhadaMehrez_0-1660242426154.png

 

please your support Im totally lost in applying this but I'm thinking if I make it more simple and add direct custom filter to set duration between start and end date, Is it possible?

GhadaMehrez_1-1660215170641.png

 

not works:

GhadaMehrez_0-1660214200334.png

 

@amitchandakI hope if you can  support in this 

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.