Forum Discussion

LeeDubs's avatar
LeeDubs
New Member
3 years ago
Solved

Normalizing Data based on attribute AND selected "Product" selected from a slicer.

I have the below data.  I have unpivoted the data to have the columns Product, Attribute, Value.  Using the following 

Normalized Value = 
VAR MinOfGroup = CALCULATE(MIN('Table'[Value]),ALLEXCEPT('Table','Table'[Attribute]))
VAR MaxOfGroup = CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Attribute]))
VAR DetailValue = MAX('Table'[Value])
RETURN DIVIDE(DetailValue - MinOfGroup,MaxOfGroup - MinOfGroup,0)

from https://dataveld.com/2017/07/29/using-dax-to-normalize-data-in-power-bi/

 

we can get the normalize values for each Attribute.  However, I really need to be able to filter the data by "Product" using a slicer.  This works but the calculation always using all products to normalize the data between 0 and 1.  How can we get the data normalized always between 0-1 on our bar chart? As you see below, the normalized value doesn't go between 0 and 1.  Many thanks to all.

 

 

ProductSpeedTorquePowerFlowSound
Big Hoopa150003857020090
Tim's Dream160005588060080
First Fury1700066112230078
Last Time Out110003437417587
Musty Mitten100001111032595
Compact Tech13500110148580091
NextGen120008096030077
Tough Tool90004540537578

 

 

 

 

 

 

 

  • LeeDubs , Try like

     

    Normalized Value =
    VAR MinOfGroup = CALCULATE(MIN('Table'[Value]),filter(allselected('Table'),'Table'[Attribute] = max('Table'[Attribute])))
    VAR MaxOfGroup = CALCULATE(MAX('Table'[Value]),filter(allselected('Table'),'Table'[Attribute] = max('Table'[Attribute])))
    VAR DetailValue = MAX('Table'[Value])
    RETURN DIVIDE(DetailValue - MinOfGroup,MaxOfGroup - MinOfGroup,0)

2 Replies

  • LeeDubs , Try like

     

    Normalized Value =
    VAR MinOfGroup = CALCULATE(MIN('Table'[Value]),filter(allselected('Table'),'Table'[Attribute] = max('Table'[Attribute])))
    VAR MaxOfGroup = CALCULATE(MAX('Table'[Value]),filter(allselected('Table'),'Table'[Attribute] = max('Table'[Attribute])))
    VAR DetailValue = MAX('Table'[Value])
    RETURN DIVIDE(DetailValue - MinOfGroup,MaxOfGroup - MinOfGroup,0)

    • LeeDubs's avatar
      LeeDubs
      New Member

      Wow.  Thank you so much.  This worked.  I have struggled and would have never gotten this.  Can you please breakdown and explain what the code in MinOfGroup (and MaxOfGroup) is doing?