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

Power Bi condition based formula

Hi, if I have data as below, does anyone know how I can embed the following forumla:

 

(0.1+sum(INITIAL_BOOKED_SHIFTS)- sum(ACTUAL_SHIFTS))/(0.1+sum(ACTUAL_SHIFTS))*100 

 

in a new column, but based on each unique "APPLICANT_COMPANY" and "WORK_AREA. 

 

screenshot 2.png

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

Please try this column expression

 

NewColumn =
VAR vActuals =
    CALCULATE (
        SUM ( Overbooking[ACTUAL_SHIFTS] ),
        ALLEXCEPT (
            Overbooking,
            Overbooking[Applicant_Company],
            Overbooking[Work_Area]
        )
    )
VAR vBooked =
    CALCULATE (
        SUM ( Overbooking[Initial_Booked_Shifts] ),
        ALLEXCEPT (
            Overbooking,
            Overbooking[Applicant_Company],
            Overbooking[Work_Area]
        )
    )
VAR vResult =
    DIVIDE (
        0.1 + vBooked - vActuals,
        0.1 + vActuals
    ) * 100
RETURN
    vResult

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Icey
Community Support
Community Support

Hi @Anonymous ,

 

You can also try to create a calculated column like this:

 

NewColumn =
VAR vActuals =
    CALCULATE (
        SUM ( Overbooking[ACTUAL_SHIFTS] ),
        FILTER (
            Overbooking,
            Overbooking[Applicant_Company] = EARLIER ( Overbooking[Applicant_Company] )
                && Overbooking[Work_Area] = EARLIER ( Overbooking[Work_Area] )
        )
    )
VAR vBooked =
    CALCULATE (
        SUM ( Overbooking[Initial_Booked_Shifts] ),
        FILTER (
            Overbooking,
            Overbooking[Applicant_Company] = EARLIER ( Overbooking[Applicant_Company] )
                && Overbooking[Work_Area] = EARLIER ( Overbooking[Work_Area] )
        )
    )
VAR vResult =
    DIVIDE ( 0.1 + vBooked - vActuals, 0.1 + vActuals ) * 100
RETURN
    vResult

 

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

 

You can also try to create a calculated column like this:

 

NewColumn =
VAR vActuals =
    CALCULATE (
        SUM ( Overbooking[ACTUAL_SHIFTS] ),
        FILTER (
            Overbooking,
            Overbooking[Applicant_Company] = EARLIER ( Overbooking[Applicant_Company] )
                && Overbooking[Work_Area] = EARLIER ( Overbooking[Work_Area] )
        )
    )
VAR vBooked =
    CALCULATE (
        SUM ( Overbooking[Initial_Booked_Shifts] ),
        FILTER (
            Overbooking,
            Overbooking[Applicant_Company] = EARLIER ( Overbooking[Applicant_Company] )
                && Overbooking[Work_Area] = EARLIER ( Overbooking[Work_Area] )
        )
    )
VAR vResult =
    DIVIDE ( 0.1 + vBooked - vActuals, 0.1 + vActuals ) * 100
RETURN
    vResult

 

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

mahoneypat
Employee
Employee

Please try this column expression

 

NewColumn =
VAR vActuals =
    CALCULATE (
        SUM ( Overbooking[ACTUAL_SHIFTS] ),
        ALLEXCEPT (
            Overbooking,
            Overbooking[Applicant_Company],
            Overbooking[Work_Area]
        )
    )
VAR vBooked =
    CALCULATE (
        SUM ( Overbooking[Initial_Booked_Shifts] ),
        ALLEXCEPT (
            Overbooking,
            Overbooking[Applicant_Company],
            Overbooking[Work_Area]
        )
    )
VAR vResult =
    DIVIDE (
        0.1 + vBooked - vActuals,
        0.1 + vActuals
    ) * 100
RETURN
    vResult

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


themistoklis
Community Champion
Community Champion

@Anonymous 

Create a new measure and not column and add the following formula.

Measure = (0.1+SUM(OVERBOOKING[INITIAL_BOOKED_SHIFTS])- SUM(OVERBOOKING[ACTUAL_SHIFTS])) / (0.1+SUM(OVERBOOKING[ACTUAL_SHIFTS]))*100

 

Then Create a table and add the fields "APPLICANT_COMPANY", "WORK_AREA and the measure above

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.