Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
powerinM
Helper II
Helper II

Top Budget Variance analysis

Hi: I am trying to create a dynamic topn dax measure which will show top variances (actual against budget) for both under and over spend. The selection of number of top variances will be controlled through the slicer. In the link below where the data model has two dimension tables (cost centre and account hierarchy). First I would like to achieve topn (e.g 3) analysis based on cost centre tbl dimension showing top 3 over budget and top 3 under budget. After achieving that, is it possible to include what are top accounts contributing the variances (from the account hierarchy dimension). Any assistance would be greatly appreciated. Thanks

 

https://www.dropbox.com/s/wl8mf77fawg4k2w/Topn.pbix?dl=0

 

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @powerinM ,

 

We can create a What if parameter in your scenario.

Then we can update your formula as below.

TopVar Analysis2 =
IF (
    ISINSCOPE ( 'Cost Centre Ranking'[Ranking group] ),
    VAR NumOfCC = Parameter[Parameter Value]
    VAR RankingGroup =
        SELECTEDVALUE ( 'Cost Centre Ranking'[Ranking group] )
    VAR TopCostCentre =
        TOPN ( NumOfCC, ALLSELECTED ( 'Cost Centre Ranking' ), [YTD Variance] )
    RETURN
        SWITCH (
            RankingGroup,
            "Over/Under Budget Cost Centre", CALCULATE ( [YTD Variance], KEEPFILTERS ( TopCostCentre ) ),
            "Other", IF (
                NOT ISINSCOPE ( 'Cost Centre Ranking'[Ranking CostCentre] ),
                VAR TopAmount =
                    CALCULATE ( [YTD Variance], TopCostCentre )
                VAR AllAmount =
                    CALCULATE ( [YTD Variance], ALLSELECTED ( 'Cost Centre Ranking' ) )
                VAR OtherAmt = AllAmount - TopAmount
                RETURN
                    OtherAmt
            )
        ),
    [YTD Variance]
)

 

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thanks for your reply. Sorry I dont think the idea of using what-if parameter sits well with topn analysis. I want to acheive the topn analysis through dax measure which is goiing to show not only top over spend cost centres against budget but also top under spend against budget depends on the number selection. After that bringing in account hierarchy dimension into the analysis.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.