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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lisapduan
New Member

Help with a Switch formula

I am trying to add a column to a report. The main data for the column is a table called Customers. I have another table called Shifts. I need all occurrances of the User field in Shifts to populate on the report. The relationship between these tables is Customers.NetSuiteSiteId = Shifts.uid. There are several instances where Customers.id does not have correlating data. I want to hard code some values based information found in Shifts.uid. This is the formula I am using and below that the error message  I'm receiving. I'm not sure what I am doing wrong. Both of the Customers.id & Shifts.uid are numeric fields.

TempDept = 
IF(
    ISBLANK(Customers[id]),
    VAR ShiftUID = 
        CALCULATE(
            MAX(Shifts[uid]),
            FILTER(
                Shifts,
                VALUE(Shifts[uid]) = VALUE(Customers[NetSuiteSiteID])
            )
        )
    RETURN
        SWITCH(
            TRUE(),
            ShiftUID IN {26, 261, 384}, 9255,
            ShiftUID = 88, 9258,
            ShiftUID = 259, 22434,
            ShiftUID = 350, 15994,
            ShiftUID = 352, 214464,
            ShiftUID = 356, 9259,
            ShiftUID = 403, 214466,
            Customers[id]
        ),
    Customers[id]
)

 Error mussage is : Function 'CONTAINSROW' does not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

I started with this formula and received an error message of : 

"A single value for column 'uid' in table 'Celayix_Shifts' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

 

TempDept = 
IF(
    ISBLANK(NS_Customer[id]),
    SWITCH(
        TRUE(),
        Celayix_Shifts[uid] IN {26, 261, 384}, 9255,
        Celayix_Shifts[uid] = 88, 9258,
        Celayix_Shifts[uid] = 259, 22434,
        Celayix_Shifts[uid] = 350, 15994,
        Celayix_Shifts[uid] = 352, 214464,
        Celayix_Shifts[uid] = 356, 9259,
        Celayix_Shifts[uid] = 403, 214466,
        NS_Customer[id]
    ),
    NS_Customer[id]
)

 

1 ACCEPTED SOLUTION
lisapduan
New Member

Thank you. I was able to simplify it and got it to work. This is what I ended up with - works great.

lisapduan_0-1738098819147.png

 

View solution in original post

2 REPLIES 2
lisapduan
New Member

Thank you. I was able to simplify it and got it to work. This is what I ended up with - works great.

lisapduan_0-1738098819147.png

 

lbendlin
Super User
Super User

Both Shifts[UID] and NS_Customer[ID]  columns would need to be of type "Whole Number" for this to work. Alternatively all your tests should have double quotes in them.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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