Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Grouped norm dist

Hi all,

 

I'm trying to make a grouped norm.dist calculation but can't yet figure it out. Below an example of my dataset (item, price):

 

chair30
couch400
table200
table150
chair11
desk100
chair60
couch180
chair100

 

If I would do a normal norm.dist calculation it wouldn't do any good since there are different products. That's why I want to group the calculation based on the product column. Each item should be calculated on it's own median and mean prices, and not on all the prices. It's btw big data with around 1K different items.

 

Any idea? Thanks in advance!

  • FreemanZ's avatar
    FreemanZ
    3 years ago

    Aha, Anonymous  try to add three columns like:

    mean2 = 
    VAR _table =
    FILTER(
        TableName, 
        TableName[item] = EARLIER(TableName[item])
    )
    RETURN
    AVERAGEX(
        _table,
        TableName[Price]
    )
    
    med2 = 
    VAR _table =
    FILTER(
        TableName,
        TableName[item] = EARLIER(TableName[item])
    )
    RETURN
    CONVERT(
        MEDIANX(
            _table,
            TableName[Price]
        ), 
        INTEGER
    )
    
    std.dev2 = 
    VAR _table =
    FILTER(
        TableName,
        TableName[item] = EARLIER(TableName[item])
    )
    RETURN
    STDEVX.P(
        _table,
        TableName[Price]
    )

     

    it worked like:

6 Replies

  • hi Anonymous 

    try to plot a table visual with the product column and measures like:

     
    mean = MEAN(TableName[Price])
    median = MEDIAN(TableName[Price])
     
    Or?
    • Anonymous's avatar
      Anonymous
      Not applicable

      I would like to have the data in a calculated column, so that won't work. Besides that I dont want the distribution over all the prices but the distribution for each product within it's own prices.

      • FreemanZ's avatar
        FreemanZ
        Super User

        hi Anonymous 

        try to create a calculated table like:
         
        Table =
        ADDCOLUMNS(
            VALUES(TableName[Product]),
            "mean",
             CALCULATE(MEAN(TableName[Price])),
            "median",
            CALCULATE(MEDIAN(TableName[Price]))
        )