Forum Discussion

zebra's avatar
zebra
Helper II
2 years ago
Solved

Create a measure or dynamic virtual table based on slicer selection that returns table

Hi All,   Would you please help in following scenario?   I have a table that contains ages and city information as follow.       I want to create the normal distribution for the age col...
  • Fowmy's avatar
    Fowmy
    2 years ago

    zebra 

    I've adjusted the calculation. Kindly review the attached file. The chart now aligns with Barcelona as expected in your results. I utilized MAX to capture the current value. The choice of MIN, SUM, or AVG would also suffice since we're dealing with a single value. The crucial aspect is employing an aggregation function to obtain the filter context value.

    Below is the DAX calculation for NORM.DIST. It now specifically takes into account the current selection by using ALLSELECTED.



    Norm.Dist = 
    VAR __Mean = CALCULATE( AVERAGE(Sheet1[Age]) , ALLSELECTED( Sheet1 ))
    VAR __StdDev = CALCULATE( STDEV.S(Sheet1[Age]) , ALLSELECTED( Sheet1 ))
    VAR __Result =  NORM.DIST( AVERAGE( Sheet1[Age]) ,__Mean  ,__StdDev,FALSE())
    RETURN
       __Result