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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ifmtakes
New Member

Creating a Distribution Graph with Filterable Variables

I'm trying to generate a distribution graph based on test results, allowing filtering by underlying variables within the sum for each run. For instance, if I select variables x1 and x2, the distribution should reflect only those variables, not the entire set (x1 + x2 + x3 + x4 ... + xn).

The challenge lies in generating bins along the x-axis and counts along the y-axis to visualize the distribution of results per run. My current idea involves creating custom dynamic bins and utilizing TREATAS to reference a table with a series. However, I am unsure if this is the correct method. I would appreciate assistance in figuring out how to implement this.

Below are my current measures and tables in the solution that does not work, 

 

Data table:

VariableRunValue
x1r1y1
x1r2y2
x1...y3
x1ry4
x2r1y5
x2r2y6
x2...y7
x2ry8
...and so on  


Messured used in y-axis:

 

Test 1 = 
//Creates a table that sum for each run
VAR _simTable = SUMMARIZE(Sim_result, Sim_result[Run], "Result", SUM(Sim_result[Value]))

//Steps used in the series table ex. 1000 = -3
VAR _roundValue = -3
//Get max & min value of t
VAR _maxRes = MAXX(_simTable, [Result])
VAR _minRes = MINX(_simTable, [Result])
//Number of bins
VAR _binsN = 100
//Bin size
VAR _midRes = _minRes + (_maxRes - _minRes) / 2 
VAR _binSize = ROUNDDOWN((_maxRes - _midRes) / (_binsN / 2 - 1), _roundValue)

//Creates new table with bins
VAR _simBinTable = ADDCOLUMNS(_simTable, "Result bin", MROUND([Result], _binSize))

VAR _simBinColumn = SELECTCOLUMNS(_simBinTable, "Result bin", [Result bin])

RETURN
CALCULATE(
    COUNTX(_simBinTable, [Result bin]),
    TREATAS(
    _simBinColumn, 
    'Simulation bins'[Value]
)
)

 


To generate table with bins for x-axis:

 

Simulation bins = 
//Creates a table that sum for each run
VAR _simTable = SUMMARIZE(Sim_result, Sim_result[Run], "Result", SUM(Sim_result[Value]))

//Steps used in the series table
VAR _steps = 1000
VAR _roundvalue = -3
//Get max & min value of t
VAR _max = MAXX(_simTable, [Result])
VAR _min = MIN(Sim_result[Value])

VAR _generate = GENERATESERIES(
    ROUNDDOWN(_min, _roundvalue), 
    ROUNDUP(_max, _roundvalue),
    _steps
)

RETURN
_generate

 

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

My current idea involves creating custom dynamic bins

That's not something you can do in Power BI.  You'd have to look at custom visuals like Deneb, or other BI tools like Tableau  which has LOD features.

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

My current idea involves creating custom dynamic bins

That's not something you can do in Power BI.  You'd have to look at custom visuals like Deneb, or other BI tools like Tableau  which has LOD features.

I looked at examples from RADCAD.com (see links) and thought they might work in my situation. Thank you for the tip; I'll explore custom visuals more deeply. Thank you!

https://radacad.com/age-banding-in-power-bi-using-treatas-dax-function-relationship-based-on-between
https://radacad.com/dynamic-banding-or-grouping-in-power-bi-using-dax-measures-choose-the-count-of-b...

I guess you can argue about the meaning of "dynamic". In Power BI you can only use buckets that you have defined beforehand.

Thank you btw, got it to work with Deneb

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.