Forum Discussion

Joaomatos2002's avatar
Joaomatos2002
Frequent Visitor
1 year ago
Solved

Building Waterfall Chart Stores Open and Close

Hello community!

I'm trying to build a Waterfall Chart in Power BI to show the monthly evolution of a network of units (e.g., branches or locations), considering:

  • In → Units opened during the month

  • Out → Units closed during the month

  • Total → Total active units at the end of the month.

My Base Table 
I have a table called 'UnitsTable' with the following fields:

UnitIDOpeningDateClosingDate
TextDateDate (can be blank)


Here´s an example of the data: 

UnitID OpeningDate ClosingDate

0012023-01-10 
0022023-02-152023-05-20
0032023-03-05 
0042023-03-282023-04-30
0052023-04-01 
0062023-05-10 
0072023-05-122023-06-15

 

What I Want to Build

I’d like to generate a Waterfall Chart with three bars per month:

  • In → Units opened

  • Out → Units closed

  • Total → Cumulative total of active units

The previous image is an example of how I want my chart to look — it was created in Excel, but I want to achieve the same output in Power BI.

What I Tried
I tried creating a measure-based approach, but the result was disorganized and hard to control within a visual. So I decided to build a calculated table to better structure the values by category and date.

Waterfall_InOut = 
VAR UniqueDates =
    DISTINCT (
        UNION (
            SELECTCOLUMNS(
                FILTER('UnitsTable', NOT ISBLANK('UnitsTable'[OpeningDate])),
                "Date", DATE(YEAR('UnitsTable'[OpeningDate]), MONTH('UnitsTable'[OpeningDate]), 1)
            ),
            SELECTCOLUMNS(
                FILTER('UnitsTable', NOT ISBLANK('UnitsTable'[ClosingDate])),
                "Date", DATE(YEAR('UnitsTable'[ClosingDate]), MONTH('UnitsTable'[ClosingDate]), 1)
            )
        )
    )

-- Entries
VAR Entries =
    ADDCOLUMNS (
        UniqueDates,
        "Category", "In",
        "Value",
        VAR CurrentDate = [Date]
        RETURN
            CALCULATE (
                COUNTROWS('UnitsTable'),
                FILTER (
                    'UnitsTable',
                    NOT ISBLANK('UnitsTable'[OpeningDate]) &&
                    EOMONTH('UnitsTable'[OpeningDate], 0) = EOMONTH(CurrentDate, 0)
                )
            )
    )

-- Exits
VAR Exits =
    ADDCOLUMNS (
        UniqueDates,
        "Category", "Out",
        "Value",
        VAR CurrentDate = [Date]
        RETURN
            -CALCULATE (
                COUNTROWS('UnitsTable'),
                FILTER (
                    'UnitsTable',
                    NOT ISBLANK('UnitsTable'[ClosingDate]) &&
                    EOMONTH('UnitsTable'[ClosingDate], 0) = EOMONTH(CurrentDate, 0)
                )
            )
    )

-- Totals
VAR Totals =
    ADDCOLUMNS (
        UniqueDates,
        "Category", "Total",
        "Value",
        VAR CurrentDate = [Date]
        RETURN
            CALCULATE (
                COUNTROWS('UnitsTable'),
                'UnitsTable'[OpeningDate] <= EOMONTH(CurrentDate, 0),
                OR (
                    ISBLANK('UnitsTable'[ClosingDate]),
                    'UnitsTable'[ClosingDate] > EOMONTH(CurrentDate, 0)
                )
            )
    )

-- Combine all data
RETURN
    UNION (
        SELECTCOLUMNS(Entries, "Date", [Date], "Category", [Category], "Value", [Value]),
        SELECTCOLUMNS(Exits,   "Date", [Date], "Category", [Category], "Value", [Value]),
        SELECTCOLUMNS(Totals, "Date", [Date], "Category", [Category], "Value", [Value])
    )

 

Example Result: 

Date Category Value

2023-01-01In1
2023-01-01Out0
2023-01-01Total1
2023-02-01In1
2023-02-01Out0
2023-02-01Total2
2023-03-01In2
2023-03-01Out0
2023-03-01Total4
2023-04-01In1
2023-04-01Out-1
2023-04-01Total4
2023-05-01In2
2023-05-01Out-1
2023-05-01Total5
2023-06-01In0
2023-06-01Out-1
2023-06-01Total4


My Visual Result: 

 


Let me know if there’s a better way to build the cumulative calculation or if there's a more elegant way to display this in a Waterfall Chart.

Thanks in advance!

  • Hi Joaomatos2002 ,

    Thank you for reaching out to Microsoft Fabric Community Forum.

     

    This is a well-structured and effective solution. The approach of creating a calculated table to categorize "In", "Out", and "Total" values per month works very well for a Waterfall Chart. It ensures clarity, accurate cumulative calculations, and avoids the complexity of using multiple measures.

    The logic covers all key aspects—unit openings, closures, and the evolving total of active units—making it both robust and visually intuitive. No changes are needed at this stage, as the current method is both scalable and reliable for your reporting

     

    Regards,

    Chaithanya.

4 Replies

  • v-kathullac's avatar
    v-kathullac
    Icon for Community Support rankCommunity Support

    Hi Joaomatos2002 ,

    Thank you for reaching out to Microsoft Fabric Community Forum.

     

    This is a well-structured and effective solution. The approach of creating a calculated table to categorize "In", "Out", and "Total" values per month works very well for a Waterfall Chart. It ensures clarity, accurate cumulative calculations, and avoids the complexity of using multiple measures.

    The logic covers all key aspects—unit openings, closures, and the evolving total of active units—making it both robust and visually intuitive. No changes are needed at this stage, as the current method is both scalable and reliable for your reporting

     

    Regards,

    Chaithanya.

  • v-kathullac's avatar
    v-kathullac
    Icon for Community Support rankCommunity Support

    Hi Joaomatos2002 ,

    we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?

    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

    Regards,

    Chaithanya

  • v-kathullac's avatar
    v-kathullac
    Icon for Community Support rankCommunity Support

    Hi @Joaomatos2002 ,

    we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?

    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

    Regards,

    Chaithanya

  • v-kathullac's avatar
    v-kathullac
    Icon for Community Support rankCommunity Support

    Hi @Joaomatos2002 ,

    we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?

    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

    Regards,

    Chaithanya