Forum Discussion

anacpint's avatar
anacpint
Helper I
4 years ago
Solved

Switch function not working

Hello,

First, I developed a measure to replace the nulls with zeros.

RFTC_NoBlank = IF(ISBLANK(SUM(Fact_RFTC[Countof])),0,SUM(Fact_RFTC[Countof]))

This the result of the measure.

After this step I created a measure to do the conditional formatting.

ColorSwitchRFT = VAR RFT = VALUES(Fact_RFTC[rft_classification])
RETURN
SWITCH(
TRUE(),
RFT="Correct", "#11A82B",
RFT="Low","#A9CC0D",
RFT="Moderate","#F2CB49",
RFT="New_Requirement", "#12ABDB",
RFT="Severe","#FF6961"
)
And this is the result:
So, this measure doesn't assume the zeros created by the first measure and don't change the color.
The final result should be something like this:

 

I'm working with live connection so I cannot create a calculated column.
Is there any way to solve this?
 
Thanks in advance.
Ana Pinto
 
  • Anonymous's avatar
    Anonymous
    4 years ago

    anacpint , this is my suggestion:

    Create a new Calculated Table called dimClassification:

     

    dimClassification = VALUES('factRFTC'[Classification])

     

    Add a relationship between the dimClassification table and factRFTC table. Make sure the relationship is Many to One, and the direction flows from the dimClassification table to the FactRFTC table.

    The measure that you use for the conditional formatting in the matrix should be changed to this:

     

    ColorSwitchRFT = 
        VAR vClassification = SELECTEDVALUE('dimClassification'[Classification])
        RETURN
            SWITCH(
                TRUE(),
                vClassification = "Correct", "#11A82B",
                vClassification = "Low","#A9CC0D",
                vClassification = "Moderate","#F2CB49",
                vClassification = "New_Requirement", "#12ABDB",
                vClassification = "Severe","#FF6961"
            )

     

    Then delete the Fact_RFTC[rft_classification] field from the Rows field from the matrix, and add dimClassification[Classification] in its place.

    Set the Conditional Formatting of the RFTC_NoBlank field in the matrix for Background Color to be Format Style "Field Value", and set the "What field should we base this on" to your [RFTC_NoBlank] measure.

     

    When I do that with some test data, this is what I get. Note that my test data in FactRFTC has no rows at all for month March 2021, but the cell for {Mar-21, Low} is correctly coloured green because it gets the value for Classification from dimClassification.

    Hope this helps.

     

     

     

25 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    anacpint , what is the tablename and fieldname on the matrix for the classification? In your ColorSwitchRFT measure you should use the classification column from the dimension table, not the fact table.

    I assume in your fact table Fact_RFTC there are no rows that have Fact_RFTC[rft_classification] = "Low"? If that is the case, then when the measure executes "VALUES(Fact_RFTC[rft_classification])", then it will never equal "Low", and so the measure result will never be "#A9CC0D".

    • anacpint's avatar
      anacpint
      Helper I

      @EyIesIT Thanks for your answer! So the fiel used is [rft_classification] and there's no dim for this field.

      The problem isn't with the "Low" values, is with the 0 values that came from the measure RFTC_NoBlank.

  • PaulDBrown's avatar
    PaulDBrown
    Community Champion

    Can you try this measure for the 0s?

    RFTC_NoBlank = COALESCE(SUM(Fact_RFTC[Countof]),0)

      • Anonymous's avatar
        Anonymous
        Not applicable

        anacpint , COLAESCE is only available in certain versions of Power BI. Instead, try

        RFTC_NoBlank = IF(ISBLANK(SUM(Fact_RFTC[Countof])),0,SUM(Fact_RFTC[Countof]))
  • Anonymous's avatar
    Anonymous
    Not applicable

    2 Reasons Why The Two Way Switch Stopped Working

    You’ve already got a brief idea about the reasons for this issue. But you need to go through them in detail to fix the issue. 

    That’s why the reasons are given below along with the solutions-

    Reason 1: Loose Connections

    One of the quite common reasons for this issue is loose connections. Typically, connections that are loose cause the wire to cease to function. 

    For two-way light switches to turn on, they must be turned in a specific direction. The direction is not too complex but simply explained in the packets of the switch. Because the connection is intermittent when the switch is left in this orientation. 

    Solution

    Check the two-way switch boxes to start troubleshooting. After that, look for any splices that are loose. Or search for a loose switch terminal. 

    You must also see if the common wire is hot or neutral . Because you need to install the wire properly. 

    Since hot and neutral wires have different functions, these wires have to be distinguished. Furthermore, any wire in the box, regardless of color, could be the source of the problem.

    The wires connecting to the switches through the little push-in holes may be visible. You can refit the connections using the screws on the sides of the switches. 

    But remember one thing! That is, while working with the wiring connections, wear safety goggles. These would prevent your eyes from directly coming in contact with the electric sparks.

    Not sure what would be the best goggles to use for it?

    Well, no worries! Because we’ve got a few suggestions here!

    These are the products you can easily trust. Because these products never disappoint.

    Remember another thing! That is, make sure to take help from the experts for this amendment. Because electricity can be extremely hazardous. 

    A loose connection is a common cause of electric shock at home. If you didn’t know, electric shock can cause damage to your   body .

    Reason 2: Wiring The Switch Incorrectly

    Wiring the switch wrongly is quite a common issue while the installation. To begin with this issue, the switch connected to the neutral wire is common. 

    Because the switch will not have a power supply in that situation. As a result, it would be unable to take the order to turn on or off.

    Plus wiring the switch in the wrong way can create additional hazards. That is, touching the switch might shock you for the wrong wiring. 

    Not only that but it would also create short circuits. This can eventually create more difficulties. 

    Plus this can also disrupt the shower isolator switch . Because connecting the wire of any switch incorrectly can result in difficulties with other switches.

    Solution

    This problem is a serious issue and needs to be fixed as soon as it’s recognized. To fix this, you must contact expert electricians. 

    Make sure you don’t take any steps regarding this mechanism yourself. Because dealing with the electrical wires is quite dangerous as you already know.

    These are the reasons and solutions for this issue of a two way switch.

     

    Regards,

    Rachel Gomez

    • anacpint's avatar
      anacpint
      Helper I

      Anonymous Hello, I think you're mistaken in your answer to me. I never talked about connection problem, Switch is a function, it is described on the the post...

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous , very funny 😂