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
rauerfc
Frequent Visitor

Measure with filter

Hello,

 

I'm calculating the weight on the week divided by the weight of the month, and my KPI is the average of their percentages by month. There is anyway that I could do this as measure that will allow me filter by plant?

Table:

YearPlantMonthWeekWeightDateConcat
2019PMRI9W11299,69501/09/2019W1September
2019PMRI9W21462,35401/09/2019W2September
2019FACF10W1901,00501/10/2019W1October
2019LDCI9W42961,65801/09/2019W4September
2019PACI11W18665,75601/11/2019W1November
2019PACI9W18665,75601/09/2019W1September
2019BMCI10W13739,29101/10/2019W1October
2019PACI10W18665,75601/10/2019W1October
2019PACI10W35548,82501/10/2019W3October
2019PACI12W18665,75601/12/2019W1December
2019BMCI12W13739,29101/12/2019W1December
2019PACI9W41743,09501/09/2019W4September
2019PACI10W41743,09501/10/2019W4October
2019BMCI9W13739,29101/09/2019W1September
2019BMCI10W41555,72201/10/2019W4October
2019LDCI10W42961,65801/10/2019W4October
2019PACI11W35548,82501/11/2019W3November
2019PACI12W35548,82501/12/2019W3December
2019PACI10W24448,17901/10/2019W2October
2019LDCI11W42961,65801/11/2019W4November
2019VLCI10W473,60201/10/2019W4October
2019VLCI11W473,60201/11/2019W4November
2019VLCI10W362,52601/10/2019W3October
2019LDCI9W38200,93501/09/2019W3September
2019PECI9W384,89301/09/2019W3September
2019PECI10W384,89301/10/2019W3October
2019PECI11W4147,70801/11/2019W4November
2019PMCI12W11182,98201/12/2019W1December
2019PMRI11W4946,72101/11/2019W4November
2019PECI10W2203,62901/10/2019W2October
2019PMCI9W11182,98201/09/2019W1September
2019VLCI9W362,52601/09/2019W3September
2019VLCI9W1143,14301/09/2019W1September
2019VLCI10W2191,50401/10/2019W2October
2019BMCI10W37783,26101/10/2019W3October
2019BMCI11W41555,72201/11/2019W4November
2019BMCI12W37783,26101/12/2019W3December
2019BMCI11W21057,27901/11/2019W2November
2019BMCI12W21057,27901/12/2019W2December
2019VLCI9W2191,50401/09/2019W2September
2019PECI9W2203,62901/09/2019W2September
2019VLCI12W473,60201/12/2019W4December
2019PECI9W4147,70801/09/2019W4September
2019PECI9W1148,46401/09/2019W1September

 

Desire output:

SUM(Weight of Week "1" on January)/SUM(Weight on January) %

SUM(Weight of Week "2" on February)/SUM(Weight on February) %

SUM(Weight of Week "3" on March)/SUM(Weight on March) %

 

Example:

 

WeekSepOctNovDecJanFebKPI
W134%33%32%35%18%23%29%
W228%27%27%29%29%28%28%
W326%28%29%31%39%39%32%
W412%13%12%6%15%11%11%
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

 

I solved it with 2 measures (which probably can be simplified to 1)

Measure = 
VAR __monthTotal =
    CALCULATE(
        SUM( 'Table'[Weight]);
        ALLEXCEPT( 'Table'; 'Table'[Month])
    )
RETURN
    DIVIDE(
        SUM( 'Table'[Weight]);
        __monthTotal;
        0
    )
Measure 2 = 
IF(
    ISFILTERED( 'Table'[Month]);
    [Measure];
    AVERAGEX(
        SUMMARIZE(
            'Table';
            'Table'[Month];
            'Table'[Week];
            "measure"; [Measure]
        );
        [measure]
    )
)

test.PNG

If this works then please accept it as the solution, kudos is also appreciated.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi

 

I solved it with 2 measures (which probably can be simplified to 1)

Measure = 
VAR __monthTotal =
    CALCULATE(
        SUM( 'Table'[Weight]);
        ALLEXCEPT( 'Table'; 'Table'[Month])
    )
RETURN
    DIVIDE(
        SUM( 'Table'[Weight]);
        __monthTotal;
        0
    )
Measure 2 = 
IF(
    ISFILTERED( 'Table'[Month]);
    [Measure];
    AVERAGEX(
        SUMMARIZE(
            'Table';
            'Table'[Month];
            'Table'[Week];
            "measure"; [Measure]
        );
        [measure]
    )
)

test.PNG

If this works then please accept it as the solution, kudos is also appreciated.

Hey @Anonymous ,

 

It worked with this small adaptation:

 

Measure = 
VAR __monthTotal =
    CALCULATE(
        SUM( 'Table'[Weight]);
        ALLEXCEPT( 'Table'; 'Table'[Month];'Table'[Plant])
    )
RETURN
    DIVIDE(
        SUM( 'Table'[Weight]);
        __monthTotal;
        0
    )
Measure 2 = 
IF(
    ISFILTERED( 'Table'[Month]);
    [Measure];
    AVERAGEX(
        SUMMARIZE(
            'Table';
            'Table'[Month];
            'Table'[Week];
            "measure"; [Measure]
        );
        [measure]
    )
)

 Thanks!

 

 

Hi @Anonymous 

It's working when Looking at Macro, but when it is filtered by Plant, the total is divided by the total of the month, I think that I didn't explain this before, but what I want is that when is filtered by Plant the  KPI is recalculated by:

SUM(Weight produced by the plant on the week)/Sum(Weight produced by the plant on the Month).

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.