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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MattReckoner
Frequent Visitor

dynamic conditional formatting with virtual table and switch

Hi, im having an issue building dynamic conditional formatting on my visual (color columns)

The reason why i need to build that are all spaces in between columns in a chart, if more trafo numbers are selected than the spaces gets bigger

 

MattReckoner_3-1683569295156.jpeg

To do that i added a table with ColorID and HEX rgb.

I want to build virtual table with all selected Serial Numbers from slicer, adding HEX rgb by matchin the ID from virtual table and colorID 

and then with switch return HEX rgb. The problem i have is that it always return same hex rgb with index nr 1 

 

MattReckoner_4-1683570594731.png

 

IndexColorTrafo =

var CurrentSelection=MAX(MeasurementsByFrequency[Serial Number])

VAR SelectedTrafoIDs = VALUES(MeasurementsByFrequency[Serial Number])

VAR NumSelectedTrafoIDs = COUNTROWS(SelectedTrafoIDs)

 

VAR VirtualTable =

    ADDCOLUMNS(

        GENERATESERIES(1, NumSelectedTrafoIDs),

        "TrafoID", SELECTEDVALUE(MeasurementsByFrequency[Serial Number]),

        "ColorID", LOOKUPVALUE(TblCSSColor[Hex rgb],TblCSSColor[ColorID],[Value])

    )

RETURN

 VAR Output= MAXX(

        VirtualTable,

        //VAR CurrentTrafoID = [TrafoID]

        //RETURN

            IF(

                NumSelectedTrafoIDs = 0,

                BLANK(),

                SWITCH(

                    TRUE(),

                    //[TrafoID]=CurrentSelection,

                    CONTAINSSTRING(SelectedTrafoIDs, CurrentSelection),

                    [ColorID],

                    BLANK()

                )

            )

    )

Return

Output

 

anyone can help?

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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