Forum Discussion

adarshsada's avatar
adarshsada
Frequent Visitor
9 months ago
Solved

Assigning a calculated column as field value

Hi everyone, 

 

I currently have a Rhino model (2D surface divided into multiple sections as seen in the below image) and I'm using it's object ID to control each section. 

What Im trying to do now is with a calculated column which has an already specified color value and assign it to the above sections. However, when I try to assign this color column as a filed value, it only considered the "last or first" value and doesnt dynamically assign the color values. 

 



This is the formula for the calculated column (SG is another column in the same table)

COL2_col =
VAR _gain = 'Test (2)'[SG]
RETURN
SWITCH(
    TRUE(),
    ISBLANK(_gain), "#FFFFFF",     
    _gain = 0, "#FFFFFF",              
    _gain <= 40, "#9ECF84",         
    _gain > 40 && _gain <= 40 + 5, "#FEC20E",  
    _gain > 40 + 5, "#DD5529",     
    "#FFFFFF"                            
)

Thanks in advance, 
 
Best, 
A
  • Hi PhilipTreacy ,

    This happens because the 3D visual is not passing the Obj ID filter to the other visuals. For the rectangles to respond correctly, both visuals must use the same Obj ID field, and the model must allow the filter to flow between them.

    Confirm both visuals use the same Obj ID. The rectangles visual uses Rose Chart[Obj ID]. The 3D visual uses Rhino[Obj ID], these need to represent the same IDs, otherwise no cross-filtering can occur.

    Check the data model relationship. Make sure there is a relationship between:
    Rhino[Obj ID] → Rose Chart[Obj ID]
    If this relationship does not exist, or is inactive, then clicking the 3D model will not filter the rectangles.

    Enable visual interactions. Even if the relationship exists, Power BI might be blocking interaction between the visuals.

    Select the 3D visual
    Go to Format → Edit interactions
    Ensure the rectangles visual is set to Filter (not “None” or “Highlight”)
    This ensures the 3D model can send filters to the rectangles visual.

    Hope this helps.
    Thank you.

10 Replies

  • Hi adarshsada ,

     

    You can achive your required output by using a measure to assign color dynamically instead of the calculation column which can only pre-calculate the value.  You can write a measure like below:

    Color_Measure = 
    VAR _gain = SELECTEDVALUE('Table'[SG])
    RETURN
    SWITCH(
        TRUE(),
        ISBLANK(_gain) || _gain = 0, "#FFFFFF",
        _gain <= 40, "#9ECF84",
        _gain <= 45, "#FEC20E",
        "#DD5529"
    )
    

     Then you can assign that measure in the fill section of the shape visual.  

     

     

    This ensures your shape color is dynamically switchable by slicer selections.  

     

    I have attached an example pbix file for your reference.

     

    Best regards,

     

  • adarshsada 

     

    You need to create a measure to assign colors in this way.  But I'm not following what you are trying to do and don't have your data.  Please supply sample data - preferably your PBIX file.

     

    Phil

     

  • adarshsada's avatar
    adarshsada
    Frequent Visitor

    Hi PhilipTreacy and all,

     

    I'm reopening this issue as I believe these's a better way of solving the problem instead of adding a button slicer. I've linked my powerBI file as well ( https://www.swisstransfer.com/d/b3e47656-e9e1-435b-b1e7-e3d0603f5926 ). 
    What I'm trying to do is trying to control the retangle using the 3D model (windows) but it does not change dynamically. 


    However, it works when I have a button slicer with the ID names. 

    This is good for a small number of ID's but isn't logical when I have alot of them. Is there a way to make it work by selecting the "ID's" in my 3D model?

     

    • v-echaithra's avatar
      v-echaithra
      Icon for Community Support rankCommunity Support

      Hi PhilipTreacy ,

      This happens because the 3D visual is not passing the Obj ID filter to the other visuals. For the rectangles to respond correctly, both visuals must use the same Obj ID field, and the model must allow the filter to flow between them.

      Confirm both visuals use the same Obj ID. The rectangles visual uses Rose Chart[Obj ID]. The 3D visual uses Rhino[Obj ID], these need to represent the same IDs, otherwise no cross-filtering can occur.

      Check the data model relationship. Make sure there is a relationship between:
      Rhino[Obj ID] → Rose Chart[Obj ID]
      If this relationship does not exist, or is inactive, then clicking the 3D model will not filter the rectangles.

      Enable visual interactions. Even if the relationship exists, Power BI might be blocking interaction between the visuals.

      Select the 3D visual
      Go to Format → Edit interactions
      Ensure the rectangles visual is set to Filter (not “None” or “Highlight”)
      This ensures the 3D model can send filters to the rectangles visual.

      Hope this helps.
      Thank you.

      • adarshsada's avatar
        adarshsada
        Frequent Visitor

        Hi v-echaithra,

        Thank you so much! The interaction between the rectangle and the 3D model was set to Highlight and hence it wasn't working. Now that I set it to Filter, it works as it should. The issue is now solved. I really appreciate your help.

         

        Best,

        A

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi adarshsada ,

    Thank you adarshsada  for your inputs.

    Just following up to see if the Response provided by community members were helpful in addressing the issue. if the issue still persists Feel free to reach out if you need any further clarification or assistance.


    Best regards,
    Chaithra E.



    • adarshsada's avatar
      adarshsada
      Frequent Visitor

      Hi v-echaithra,

      I still havent been able to find a fix to my issues, unfortunately. It would be great if you could check my .PBIX file and let me know if I'm doing something wrong. 

       

      Best regards,

      A

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi PhilipTreacy ,

    Thank you DataNinja777  for your inputs.

    I just wanted to check if the issue has been resolved on your end, or if you require any further assistance. Please feel free to let us know, we’re happy to help!


    Thank you 
    Chaithra E.

     

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi adarshsada ,

    May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.

    Thank you.