Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Issue in Dax (Caluclated column).

  Hello everyone,    I am a novice user in power bi, slowly upgrading myself to multiple scenarios, have recently came across a situation to resolve the output by random change in the rate value p...
  • Syndicate_Admin's avatar
    5 years ago

    There @Syndicate_Admin@kxj54590

    Download this PBIX file with code shown below

    This calculation should be done with a Measure rather than a Column. Here's the DAX for the Measure

    dynamic_bin_measure = SWITCH (
    
    TRUE, 
    
    Dyn_Rate[Dyn_Rate Value] = 0, 0,
        
    Dyn_Rate[Dyn_Rate Value] <= SELECTEDVALUE(Input[2 Tier Range]) , 1,
    
    Dyn_Rate[Dyn_Rate Value] > SELECTEDVALUE(Input[2 Tier Range]) &&  Dyn_Rate[Dyn_Rate Value] <= SELECTEDVALUE(Input[3 Tier Range]), 2,
        
    Dyn_Rate[Dyn_Rate Value] > SELECTEDVALUE(Input[3 Tier Range]) &&  Dyn_Rate[Dyn_Rate Value] <= SELECTEDVALUE(Input[4 Tier Range]), 3,
     
    Dyn_Rate[Dyn_Rate Value] > SELECTEDVALUE(Input[4 Tier Range]) &&  Dyn_Rate[Dyn_Rate Value] <= SELECTEDVALUE(Input[5 Tier Range]), 4,
        
    Dyn_Rate[Dyn_Rate Value] > SELECTEDVALUE(Input[5 Tier Range]), 5,
      
    0
    
    )
        

    However there is another problem. You are testing for values of [Dyn_Rate Value] which can be anything from 0 to 100. But all of the Tier values are between 0 and 1 so as soon as [Dyn_Rate Value] is greater than 0, all of your dynamic bin values will be 5.

    tiers.png

    You either need to adjust the Tier values, or adjust the values that [Dyn_Rate Value] can take, or divide [Dyn_Rate Value] by 100 to make it always be between 0 and 1.0.

    In the file above I've divided [Dyn_Rate Value] by 100.

    tiers2.png

    Regards

    Phil