cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
magsb
Frequent Visitor

New Measure with IF and Switch

Hi,

 

I am a very new to Power BI, so I would greatelly appreciate any help!

I am trying to create a new measure "WHS Modification":

 

I have four columns: Warehouse,Vendor, Location, Item

The column Warehouse need to be modified by creating new column called "WHS Modification", but the changes in Warehosue column need to be done only for  some records based on Product and Vendor:

 

If Vendor="PBC" and Location="OF" and Item in (Cakes, Cookies) then WHS=ABC
If Vendor="PBC" and Location = "OF" and item not in (Cakes, Cookies) then WHS=DEF
If Vendor not "PBC" and "Loation"="OF" then "SCC"
else Warehouse data for the specific combinations of Vendor, Location and WHS.

Thanks!

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @magsb ;

You could create a measure as follows:

Measure =
VAR _Ven =
    MAX ( [Vendor] )
VAR _Item =
    MAX ( [Item] )
VAR _Loca =
    MAX ( [Location] )
RETURN
    IF (
        _Ven = "PBC"
            && _Loca = "OF"
            && _Item IN { "Cakes", "Cookies" },
        "ABC",
        IF (
            _Ven = "PBC"
                && NOT ( _Loca ) = "OF"
                && _Item IN { "Cakes", "Cookies" },
            "DEF",
            IF ( NOT ( _Ven ) = "PBC" && _Loca = "OF", "SCC", BLANK () )))

The final output is shown below:

vyalanwumsft_0-1629703439338.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @magsb ;

You could create a measure as follows:

Measure =
VAR _Ven =
    MAX ( [Vendor] )
VAR _Item =
    MAX ( [Item] )
VAR _Loca =
    MAX ( [Location] )
RETURN
    IF (
        _Ven = "PBC"
            && _Loca = "OF"
            && _Item IN { "Cakes", "Cookies" },
        "ABC",
        IF (
            _Ven = "PBC"
                && NOT ( _Loca ) = "OF"
                && _Item IN { "Cakes", "Cookies" },
            "DEF",
            IF ( NOT ( _Ven ) = "PBC" && _Loca = "OF", "SCC", BLANK () )))

The final output is shown below:

vyalanwumsft_0-1629703439338.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

PaulDBrown
Super User
Super User

please follow the suggestions in this thread to help us help you:

/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!