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
Anonymous
Not applicable

Condition Formula

Does anyone know how I can embed the following formula 100(sum(KPI1)/sum(KPI1_COUNT))* as a new column. With the sum being based on each unique "Applicant_Company" and "Work_Area" and each month (See below)

 

screenshot.png

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

Hi @Anonymous ,

 

According to my understanding , you want to calculate SUM(KPI1)/SUM(KPI1_COUNT) based on three categories,right?

 

You could use EARLIER() or ALLEXCEPT() function shown below:

Column =
CALCULATE (
    SUM ( 'Table'[KPI1] ) / SUM ( 'Table'[KPI1_COUNT] ),
    FILTER (
        'Table',
        'Table'[Applicant_Company] = EARLIER ( 'Table'[Applicant_Company] )
            && 'Table'[Work_Area] = EARLIER ( 'Table'[Work_Area] )
            && 'Table'[Date].[MonthNo] = EARLIER ( 'Table'[Date].[MonthNo] )
    )
)
Column 2 =
CALCULATE (
    SUM ( 'Table'[KPI1] ) / SUM ( 'Table'[KPI1_COUNT] ),
    ALLEXCEPT (
        'Table',
        'Table'[Applicant_Company],
        'Table'[Work_Area],
        'Table'[Date].[MonthNo]
    )
)

Here is the final output :

1.22.2.1.PNG

 

Please take a look at the pbix file here.

 

Best Regards,
Eyelyn Qin
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-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

According to my understanding , you want to calculate SUM(KPI1)/SUM(KPI1_COUNT) based on three categories,right?

 

You could use EARLIER() or ALLEXCEPT() function shown below:

Column =
CALCULATE (
    SUM ( 'Table'[KPI1] ) / SUM ( 'Table'[KPI1_COUNT] ),
    FILTER (
        'Table',
        'Table'[Applicant_Company] = EARLIER ( 'Table'[Applicant_Company] )
            && 'Table'[Work_Area] = EARLIER ( 'Table'[Work_Area] )
            && 'Table'[Date].[MonthNo] = EARLIER ( 'Table'[Date].[MonthNo] )
    )
)
Column 2 =
CALCULATE (
    SUM ( 'Table'[KPI1] ) / SUM ( 'Table'[KPI1_COUNT] ),
    ALLEXCEPT (
        'Table',
        'Table'[Applicant_Company],
        'Table'[Work_Area],
        'Table'[Date].[MonthNo]
    )
)

Here is the final output :

1.22.2.1.PNG

 

Please take a look at the pbix file here.

 

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

Anonymous
Not applicable

Hi thats great thanks! can I ask, if both the KPI1 and KPI_COUNT columns are 0, do you know how within the formula I can put a IF clause which will make the calculation revert to 100?

Hi @Anonymous ,

 

The DIVIDE() function was designed to automatically handle division by zero cases.

 

See the differences between DIVIDE() and / here.

1.27.1.1.PNG

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

 

Anonymous
Not applicable

Not sure I follow exacly, maybe you could knock up a mock table to show what you currently have and what the expected result would be with the additional column? 

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.