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
MBWATSON
Helper II
Helper II

M code help

Good afternoon,

 

I have a DAX formula that I would like to use in Power Query but am not even sure where to start. Hoping to get some guidance here. The code looks like this

 

ROLE =
VAR ChangedBy = '_VIB Report 2022 07'[STATUS CHANGED BY]
VAR Department = '_VIB Report 2022 07'[DEPARTMENT]
RETURN
    SWITCH (
        TRUE (),
        ChangedBy = "DYER, HEIDI S"
            && Department = "WILSONVILLE", "PCP",
        ChangedBy = "MINGS, JENNIFER ANNE"
            && Department = "TANASBOURNE", "CLINIC APC",
        ChangedBy = "HOJNACKI, LAUREN A"
            && Department = "GLISAN", "CLINIC APC",
        "VIB"
    )
 
Thank you!
6 REPLIES 6
wdx223_Daniel
Super User
Super User

NewStep=Table.AddColumn(#"_VIB Report 2022 07","ROLE",each List.Skip({{{"DYER, HEIDI S","DYER, HEIDI S"},"PCP"},{{"MINGS, JENNIFER ANNE","TANASBOURNE"},"CLINIC APC"},{{"HOJNACKI, LAUREN A","GLISAN"},"CLINIC APC"}},(x)=>x{0}<>{[STATUS CHANGED BY],[DEPARTMENT]}){0}?{1}? ?? "VIB")

Perhaps the better question is this. I have a table that has a column of names and a column of roles. There are a handful of people in the names column that have multiple roles depending on the deparment (also a column). What I would like to do is change those roles in the role column while retaining the role for the other folks in the name column. Does that make sense?

Here is a screen shot of the data

 

MBWATSON_0-1665763462539.png

Thank you!

 

ronrsnfld
Super User
Super User

    "am not even sure where to start"

Start by providing an explanation of what you want the code to accomplish; an example of the raw data; and an example of the desired output from your sample raw data.

@ronrsnfld please see message 4. You will find the screenshot there as well as the "whys". Thanks!

@MBWATSON I don't find the screenshot helpful at all to me.  Maybe someone else will understand it better.

  • It is a screenshot which I can't copy/paste into my version of excel.
    • Parts of the table are "cut off".
  • I don't see any description of the rule for how you want to change the roles.
  • I don't see an example of the expected results after you apply the rules.

@ronrsnfld I was able to figure it out but thank you!

 

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.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

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.