Forum Discussion

shahrukhgaffar0's avatar
shahrukhgaffar0
Regular Visitor
10 months ago
Solved

Help With Waterfall Visual

I'm working on a custom waterfall chart in Power BI using a calculated table and DAX logic. I’ve managed to get most of it working correctly — including custom sorting and indexing — but I'm stuck on...
  • v-achippa's avatar
    v-achippa
    9 months ago

    Hi @shahrukhgaffar0,

     

    Based on your requirement, you need to manipulate the Start and End values for each bar in your calculated table. Specifically for all bars except Target, the waterfall logic should be cumulative.

    For the 'Target' bar, you need to override the cumulative logic and set Start = 0 and End = Target Value.

     

    You can modify your calculated table to include StartValue and EndValue columns. 

    Use this updated DAX:

     

    WaterFall Data Table =
    VAR YTD_Table =
        ADDCOLUMNS(
            SELECTCOLUMNS(
                ROW("Category", "YTD Revenue", "Amount", [1.2.Cumulative Closed Sales]),
                "Category", [Category],
                "Amount", [Amount]
            ),
            "StartValue", 0,
            "EndValue", [Amount]
        )
    
    VAR NORMALISED_SALES =
        ADDCOLUMNS(
            SUMMARIZE(
                FILTER(
                    'Sales Data',
                    'Sales Data'[Stage] IN {
                        "4.Submitted Proposal",
                        "5.Tender Evaluation",
                        "6.Negotiations",
                        "7.Verbal Award"
                    }
                ),
                'Sales Data'[Opportunity Name]
            ),
            "Category", 'Sales Data'[Opportunity Name],
            "Amount", CALCULATE(
                [WaterFall Norm Sales],
                'Sales Data'[Opportunity Name] = EARLIER('Sales Data'[Opportunity Name])
            )
        )
    
    VAR Normalised_Sales_Final =
        ADDCOLUMNS(
            SELECTCOLUMNS(NORMALISED_SALES, "Category", [Category], "Amount", [Amount]),
            "StartValue", BLANK(), // Will be calculated in visuals
            "EndValue", [Amount]
        )
    
    VAR VARIENCE =
        ADDCOLUMNS(
            SELECTCOLUMNS(
                ROW("Category", "Variance", "Amount", [Variance]),
                "Category", [Category],
                "Amount", [Amount]
            ),
            "StartValue", BLANK(),
            "EndValue", [Amount]
        )
    
    VAR TARGET_VALUE =
        ADDCOLUMNS(
            SELECTCOLUMNS(
                ROW("Category", "Target", "Amount", [3.2.Cumulative Target Sales]),
                "Category", [Category],
                "Amount", [Amount]
            ),
            "StartValue", 0, // Force start from zero
            "EndValue", [Amount]
        )
    
    RETURN
        UNION(
            YTD_Table,
            Normalised_Sales_Final,
            VARIENCE,
            TARGET_VALUE
        )

     

    Thanks and regards,

    Anjan Kumar Chippa