Search code examples
powerbimeasurenormalize

Normalize measure to interval [0, 1] in Power BI


I have a dataset in 'Table1' as follows sales and calculate a measure of "Revenue per Customer" as follows

Revenue Per Customer = 

DIVIDE(SUM('Table1'[Revenue (GBP)]), SUM('Table1'[Number Of Customers]))

As a final step, I try to normalize the measure above into interval [0,1] so that 1 would be max value as follows

Normalized Revenue Per Customer = 

VAR Xi = 
DIVIDE(SUM('Table1'[Revenue (GBP)]), SUM('Table1'[Number Of Customers])) 
VAR MnX =     
MINX('Table1', 
DIVIDE(SUM('Table1'[Revenue (GBP)]), SUM('Table1'[Number Of Customers]))) 
VAR MxX =  
MAXX('Table1', DIVIDE(SUM('Table1'[Revenue (GBP)]), SUM('Table1'[Number Of Customers])))

RETURN DIVIDE(Xi-MnX , MxX - MnX)

but does not work. In the end, I need to add the normalized measure to a visual and select via filters the year, so the normalized measure should be automatically calculated per any year combination, i.e. 2019 or 2019 and 2020 etc.

Any ideas how to make this work?


Solution

  • Normalized Revenue Per Customer = 
    
    VAR Xi = [Revenue Per Customer]
    VAR MnX = MINX(
        ALLSELECTED(Table1)
        , [Revenue Per Customer]
        )
    VAR MxX = MAXX(
             ALLSELECTED(Table1)
        , [Revenue Per Customer]
        )
    
    RETURN DIVIDE(Xi-MnX , MxX - MnX)
    

    enter image description here

    enter image description here

    Normalized Revenue Per Customer = 
    
    VAR Xi = [Revenue Per Customer]
    VAR MnX = MINX(
        ALL(Table1[Store]) -- ALLSELECTED(Table1[Store]) if you plan to filter by store.
        ,[Revenue Per Customer]
        )
    VAR MxX = MAXX(
        ALL(Table1[Store]) -- ALLSELECTED(Table1[Store]) if you plan to filter by store.
        ,[Revenue Per Customer]
        )
    
    RETURN DIVIDE(Xi-MnX , MxX - MnX)
    

    enter image description here

    enter image description here