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

Complex Tier Calculations with Nested If Statements

Hey y'all, I am having a hard time doing something that I did in Excel in Power Bi. I am esimating utility costs for different building types. I have the building type defined along with its annual electricity use and its peak demand. For the $$ calculation, there are three different schedules and each buildings falls under a schedule depending on its daily electricity consumption and its peak demand. So for example, if daily consumption is <15,000 kWh and demand < 50 kW, you fall within scenario 1. If daily consumption is >15,000 kWh and demand < 50 kW, you fall within scenario 2. If demand > 50 kW, you fall withing scenario 3. Then, under each scenario, there are different rates applied to daily consumption and to the demand, and these charges are often done in a tiered manner. So for example, in scenario 2, daily consumption from 0-15,000 kWh is charged at $0.5, and from 15,000-30,000 at $0.4 and so on. In the same scenario 2, peak demand from 0-30 kW is charged at $5 and from 31-50 kW, at $7. 

 

Sorry if this made no sense, but I was able to do this pretty easily in Excel.... now I am unsure of how to do it in Power Bi. Any help, please? Thank y'all 🙂 

 

Here is a link with the tier structure for different scenarios and then a box of sample analysis with my main equation. Thank you so much: https://1drv.ms/x/s!AtT91FiUJMdTgmY6risd9ngx33wj?e=Ggkpxg

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

Hi @Anonymous ,

For special reasons I can't view your files and upload the sample file I created, which I uploaded to you in the form of screenshots. Please have a try.

My raw data:

vpollymsft_0-1660634891967.png

According to you conditions, I created two columns.

scenary =
IF (
    'Table'[daily consumption] <= 15000
        && 'Table'[demand] <= 50,
    "scenario 1",
    IF (
        'Table'[daily consumption] > 15000
            && 'Table'[demand] < 50,
        "scenario 2",
        "scenario 3"
    )
)
Column =
VAR _scenario1 =
    IF (
        'Table'[scenary] = "scenario 1",
        'Table'[daily consumption] * 0.5,
        BLANK ()
    )
VAR _scenery2 =
    IF (
        'Table'[scenary] = "scenario 2",
        15000 * 0.5 + ( 'Table'[daily consumption] - 15000 ) * 0.4,
        BLANK ()
    )
VAR _secery3 =
    IF (
        'Table'[scenary] = "scenario 3",
        15000 * 0.5 + ( 'Table'[daily consumption] - 15000 ) * 0.4,
        BLANK ()
    )
RETURN
    IF (
        'Table'[scenary] = "scenario 1",
        _scenario1,
        IF (
            'Table'[scenary] = "scenario 2",
            _scenery2,
            IF ( 'Table'[scenary] = "scenario 3", _secery3, BLANK () )
        )
    )

vpollymsft_1-1660635032022.png

 

 

If I have misunderstood your meaning, please provide screenshoots with some sample data and your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

1 REPLY 1
v-rongtiep-msft
Community Support
Community Support

Hi @Anonymous ,

For special reasons I can't view your files and upload the sample file I created, which I uploaded to you in the form of screenshots. Please have a try.

My raw data:

vpollymsft_0-1660634891967.png

According to you conditions, I created two columns.

scenary =
IF (
    'Table'[daily consumption] <= 15000
        && 'Table'[demand] <= 50,
    "scenario 1",
    IF (
        'Table'[daily consumption] > 15000
            && 'Table'[demand] < 50,
        "scenario 2",
        "scenario 3"
    )
)
Column =
VAR _scenario1 =
    IF (
        'Table'[scenary] = "scenario 1",
        'Table'[daily consumption] * 0.5,
        BLANK ()
    )
VAR _scenery2 =
    IF (
        'Table'[scenary] = "scenario 2",
        15000 * 0.5 + ( 'Table'[daily consumption] - 15000 ) * 0.4,
        BLANK ()
    )
VAR _secery3 =
    IF (
        'Table'[scenary] = "scenario 3",
        15000 * 0.5 + ( 'Table'[daily consumption] - 15000 ) * 0.4,
        BLANK ()
    )
RETURN
    IF (
        'Table'[scenary] = "scenario 1",
        _scenario1,
        IF (
            'Table'[scenary] = "scenario 2",
            _scenery2,
            IF ( 'Table'[scenary] = "scenario 3", _secery3, BLANK () )
        )
    )

vpollymsft_1-1660635032022.png

 

 

If I have misunderstood your meaning, please provide screenshoots with some sample data and your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

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.