Forum Discussion

thameem10's avatar
thameem10
Frequent Visitor
1 year ago
Solved

Dynamic Column calculation based on Slicer Selection

I have 3 Tables "Variables", "Sales Data" and "Scrap Ratio".

 

The Variable Table holds the year from 2009 to 2025. Scrap Ratio has the Age Number wise Category description and Scrappage rate and sales data has the following data points (sample data below with excel formulas and pivot).

 

Sold MonthBusiness DivisionSales GroupModel GroupCountAgeAge BucketRemain RateActive Units
2009TruckRetailMDL180399>1000
2010TruckRetailMDL175299>1000
2011TruckRetailMDL173599>1000
2012TruckRetailMDL194999>1000
2013TruckRetailMDL1168099>1000
2014TruckRetailMDL1168510N-90.6611114
2015TruckRetailMDL127959N-80.6831909
2016TruckRetailMDL122218N-70.7191597
2017TruckRetailMDL120857N-60.761585
2018TruckRetailMDL118506N-50.8031486
2019TruckRetailMDL110595N-40.852902
2020TruckRetailMDL18144N-30.907738
2021TruckRetailMDL18233N-20.96790
2022TruckRetailMDL117682N-10.9851741
2023TruckRetailMDL113981N0.9851377
2024TruckRetailMDL124290CY12429

 

Excel Formulas :

Age: =IF(Variables!$B$1-'NV Data'!$A2>10,99,Variables!$B$1-'NV Data'!A2)

Age Bucket =IFERROR(XLOOKUP(F2,'Scrap Ratio'!A:A,'Scrap Ratio'!B:B),">10")

Remaining Rate =IFERROR(XLOOKUP(F2,'Scrap Ratio'!A:A,'Scrap Ratio'!C:C),0)

 

The Age column in the "Sales Data" table should reflect the Age difference between the Selected / Filtered year and Sold Month. This should dynamically change upon using the slicer and the overall Pivot / Power BI Matrix should change accordingly.

 

Scrap Ratio Table

Age NoAge NRemain Rate
0CY1
1N0.985
2N-10.985
3N-20.96
4N-30.907
5N-40.852
6N-50.803
7N-60.76
8N-70.719
9N-80.683
10N-90.661

 

I want to replicate this excersise in Power BI, where the Power BI Matrix has to reflect the pivot structure for the selected / filtered year in the Slicer (Table - Variable).

 

In this case 2023 is selected in the Slicer, basis which "Age" column calculated and then the this pivot got refreshed.

 

I would apriciate your support in resolving this one.

 

amitchandak Ashish_Mathur 

5 Replies

  • Hi,

    Not sure how much i can help but i would like to try.  Share the download link of the MS Excel file with your formulas/Pivot Tables already there.  It will be easier to understand your logic from there and convert it into measures.

      • thameem10's avatar
        thameem10
        Frequent Visitor

        Hi Ashish, Thanks a lot for solving this in Power BI. I apriciate your expertise in this space.