Forum Discussion

ifmtakes's avatar
ifmtakes
New Member
2 years ago
Solved

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

 

 

 

  • 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.

4 Replies