Forum Discussion

Power_BI_Help's avatar
6 years ago

Custom Bin on Measure

Hello Power BI forums,

I've read a few solutions about this but can't seem to get this correct. I'm trying to create a custom bin based on a measure (see file attached). This is for a trading stock situation, where you have an entry then can have multiple exits (selling part of the position). The measure I created creates a weighted profit (i.e. one number) for per each entry. I want a histogram of the weighted profits by predefined bins (e.g. 0-5, 5-10%, etc).

 

I removed my attempts so you don't see the clutter, but I was trying:
-If statement is >min && <=Max
-I read a solution that used the Countrows then filter to the bins, there must be something off in my filter formulas, I keep messing with it.

 

My existing File: 

https://www.dropbox.com/s/ydee6f7p788bk6e/Weighted%20Positions%20Custom%20Bins.pbix?dl=0

 

The one table I have that shows "Profit weight by trade", there could be another solution to restructure the measure. Thanks for the help in advance, it's a race to the solution! 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Power_BI_Help ,

     

    Sorry i don't quite understand what you want, can you show some details?

    • Power_BI_Help's avatar
      Power_BI_Help
      Helper I

      Below is an excel replicate of the table that I am trying to output based on the given input tables. I was able to calculate the weight profit if I am able to use the axis as trade ID, but then I am unable to bin them appropriately. I think I need a formula that "creates" the weighted profit X trade ID table in the background and then counts between the min and max of the "bin" table. I'm just struggling to create that in a DAX.

      https://imgur.com/a/NScZ7AW