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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
LeeDubs
New Member

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_2-1677542664450.png

 

 

 

 

LeeDubs_0-1677542610839.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@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)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@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)

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?  

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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