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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
CMoppet
Helper IV
Helper IV

SELECTED VALUE in a Custom Column?

Hello

I have attached a link to a test file to demonstrate a piece of work I am stuck on at the moment.    https://drive.google.com/file/d/1s5QikoceDHnJktFW0fZAAR8SBL26uOcu/view?usp=sharing

 

And this is the specific custom column that I'm stuck on...

 

MTBFTest = 
VAR MonthYear = [Month/Year]
VAR MachineBrand = [Machine Brand]
VAR MachineType = [Machine Type]
VAR Age = [Age Bracket]
VAR Market = [Market]
VAR _Results = SUMX(FILTER(ALL('RepsSummary'),'RepsSummary'[Age Bracket]=Age && [Machine Brand]=MachineBrand && [Machine Type]=MachineType && [Market]=Market && [Month/Year]=MonthYear),[Repairs1])
RETURN
IF([Repairs1]>0,DIVIDE([Operational Weeks in Reporting Month],[Repairs1]),[Operational Weeks in Reporting Month])

 

 

Please can someone help me adapt the custom column above so that the bar chart beneath it updates the results if just some of the variables outlined in the formula are selected?  For example, if someone chooses Machine Brand 'ABC' in a slicer and doesn't select anything from the other slicers, the result for August 2023 should be approximately 52.5, because I want it to disregard the Age, Market, Type and perform the DIVIDE calculation at just a Machine Brand level.  Similarly, users should be able to select just a Market and a Machine Type, and get the result for those disregarding the Age.

 

Is the problem with the way I've written the column?  How can I make the variables flexible rather than mandatory to get a correct result?

 

Many Thanks in advance

 

 

1 ACCEPTED SOLUTION

Instead of column in y axis, Use measure. I have created this measure according to you calculation, you have mentioned in your replay.

Test =
DIVIDE([Operational Weeks in Reporting Month], SUM(BaseSummary[Repairs1]))

 

For 52.6, Check this:

shafiz_p_3-1725467446389.png

 


For 51.6, Check the result (For same setting, no relation developed, only Base table used, bring all necessary values in Base table)

shafiz_p_0-1725466596167.png

 

For Third case, I have manually filtered your table, and done manual calculation, it is not the same as you want. Why is this different?

 

For, Machine Type = ABC Element, Age Bracket = 1Yr1d-5Yr, Month/Year = Aug 2023, check this:

shafiz_p_1-1725467075979.png

 

Tried manual calculation, and not getting your mentioned value which is 74.7 instead I found 63.6 and column chart showing me that value. Check the below image.

 

shafiz_p_2-1725467166388.png

 

Hope this helps!!

View solution in original post

6 REPLIES 6
CMoppet
Helper IV
Helper IV

@shafiz_p  Following on from my post above, here's what I mean....

 

The value of 42 shown in the bar chart below is the average of the MTBF results 19 and 65 (highlighted.

However, what it should do in this scenario is add up all the August values in 'Sum of Total Active MCs', multiply this by 4.43 (weeks in period) and then divide by the sum of all the numbers in the August Repairs1 column.

CMoppet_1-1725465254711.png

 

 

shafiz_p
Super User
Super User

Hi @CMoppet  I think you had problem with the relationship between tables. Many to many relationship with both directional may lead to incorrect results. I have deleted all the relationship and used TreatAs function in the calculated column.

 

Updated Repairs1 Column formula:

Repairs1 =
VAR MonthYear = [Month/Year]
VAR MachineBrand = [Machine Brand]
VAR MachineType = [Machine Type]
VAR Age = [Age Bracket]
VAR Market = [Market]
VAR _Results =
CALCULATE(
    SUMX(FILTER(ALL('RepsSummary'),'RepsSummary'[Age Bracket]=Age && [Machine Brand]=MachineBrand && [Machine Type]=MachineType && [Market]=Market && [Month/Year]=MonthYear),[Total No. of Breakdowns]),
    TREATAS(VALUES(BaseSummary[Month/Year]), RepsSummary[Month/Year])
)
RETURN
_Results


Updated MTBFTest Column :
MTBFTest =

IFERROR(DIVIDE([Operational Weeks in Reporting Month],[Repairs1]),[Operational Weeks in Reporting Month])
 
After that I have found the updated Bar chart with Aug 2023 is 53.22, slightly higher value than you have mentioned.
Check this:

shafiz_p_0-1725463586452.png

 

I think this is what you want!

Hope this helps!!
If this solved your problem, please accept it as a solution!!

 

Best Regards,
Shahariar Hafiz

Ah! I think I know where the results are coning from!  When you add a slicer, it averages the results in the MTBFTest column, rather than performing the DIVIDE calculation again from scratch.  

 

So...if the user doesn't select any age bracket or machine type, it should simply calculate the total number of machines within the brand, across all markets, and the same for repairs, and use these in the DIVIDE calculation.  Does that make sense?

@shafiz_p   Hello 🙂  I have replcated your work and the result is now correct in the example of choosing a single brand; ABC.  However, if I test it again slicing by type and/or age, it doesn't seem to work for me.  For example, if you select Machine Type 'ABC Element', August 2023 should be circa 51.6 (4450 machines * 4.43 weeks, all divided by 382 repairs), and if you then also select the Age Bracket '1Yr1d - 5Yrs' the result for August should be circa 74.7. 

Please can you help me spot how to correct this?

Instead of column in y axis, Use measure. I have created this measure according to you calculation, you have mentioned in your replay.

Test =
DIVIDE([Operational Weeks in Reporting Month], SUM(BaseSummary[Repairs1]))

 

For 52.6, Check this:

shafiz_p_3-1725467446389.png

 


For 51.6, Check the result (For same setting, no relation developed, only Base table used, bring all necessary values in Base table)

shafiz_p_0-1725466596167.png

 

For Third case, I have manually filtered your table, and done manual calculation, it is not the same as you want. Why is this different?

 

For, Machine Type = ABC Element, Age Bracket = 1Yr1d-5Yr, Month/Year = Aug 2023, check this:

shafiz_p_1-1725467075979.png

 

Tried manual calculation, and not getting your mentioned value which is 74.7 instead I found 63.6 and column chart showing me that value. Check the below image.

 

shafiz_p_2-1725467166388.png

 

Hope this helps!!

Oh my goodness!  This works!!!  Thank you so, so much.  I can't tell you how long I've spent trying to fix this!    I'm so grateful 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors