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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
anwilkins
Resolver II
Resolver II

How to create large groups / buckets in power query

Seeking an easy method to create a new column that groups 126 insurance vendors into 5 categories: Commercial, Grant, Medicaid, Medicare, Uninsured or N/A. (The N/A bucket will be the catch all for when new insurance vendors are added an we [the data team] are not notified. Once I see a person fall into that category I can update the list with the new company.)

 

In the past I created a new column using the following (very long) DAX statement (ex... 

 

   Ins Grps = 

        If(MERGE_BillingSUMMARY[Credited Insur Carrier] IN {"Aetna", "All Savers UHC", "BCBS - Med Adv. - OTP", "BCBS NC", "Beacon Health Options", "Zelis"}, "COMMERCIAL",

        IF(MERGE_BillingSUMMARY[Credited Insur Carrier] IN {"Alliance - Medicaid","AmeriHealth - Medicaid", "COVID Medicaid", "Eastpoint - Medicaid", "Healthy Blue - Medicaid", "Healthy Blue -  "WellCare-Medicaid"}, "MEDICAID",

 And so on for the other 3 categories...

 

Is there a way in power query to create this column so I do not have to manually type all 126 insurance companies?

Here is the sample data:

 

MEDICAID COMMERCIALMEDICAREUNINSUREDN/A
Alliance - MedicaidAetnaBCBS - Medicare Advantage**No Insurance CarrierCHC Staff COVID Test
AmeriHealth - MedicaidAll Savers UHCFirst Carolina MedicareABC GrantDepartment of Veterans Affairs
AmeriHealth - NCHC MedicaidBCBS - Med Adv. - OTPFirst Carolina Medicare - OTPAdolescent Disaster GrantImagine 360 - GPA
CAMFBCBS NCGateway Health Medicare AssuredAdult Disaster GrantMegellan PPO
CAMF & IPBeacon Health OptionsHealthy Blue - MedicareASOUD-Trillium IPRSMeritian Health
Cardinal Innovations HealthcareBehavioral Health SystemsHumana HMO MedicareBeaufort County Department of Social ServicesTriWest Healthcare Alliance
Cardinal Innovations MedicaidBenefit Management ServicesHumana PPO MedicareBladen DPI GrantUHC - Surest
Carolina Complete - NCHC MedicaidBoon AdministratorsMedicareBladen School 
Carolina Complete Health - MedicaidBright Health PlanMedicare - OTPBrunswick County 
COVID MedicaidCarolina Behavioral Health AllianceMedicare - RailroadBrunswick County School 
Eastpoint - MedicaidCIGNAMedicare - Railroad OTPBrunswick Court 
Eastpointe - MedicaidComPsychMedicare SupplementalCOC Scholarship 
Healthy Blue - MedicaidCorporate Benefits ServicesNew Hanover Department of Social ServicesColumbus School 
Healthy Blue - NCHC MedicaidElderhausUnited Healthcare MedicareEastpoint - IPRS 
Healty Blue - MedicaidHumana CommerciaUnited HealthCare OTPEastpointe - IPRS 
Magellan Health ServicesInsurance Benefit Systems AdministratorsWellCare MedicareEshelman Grant 
MedicaidMedcost Preferred Federal Probation 
Medicaid Family Plan WaiverMultiPlan Grant/ORH MAP 
NC HealthchoicePlanned Administrators Inc Grant/United Way 
Partners Behavioral Health ManagementTricare East Region HARRTS 
Partners MedicaidUHC - Bind Humana 
Sandhills CenterUMR IFPS Grant 
Trillium MedicaidUnited Health Care Student Resources International Union of Operating Engineers 
UHC Community Plan - MedicaidUnited Healthcare New Hanover County Detention Center 
UHC Community Plan - NCHC MedicaidUnited HealthCare Shared Services New Hanover County Schools 
Vaya Health MedicaidUnitedHealthOne/Golden Rule NHRMC 
WellCare - MedicaidVA Administration Center NHRMC - Ryan White 
WellCare - NCHC MedicaidZelis OTP-Self Pay 100% 
WellCare-Medicaid  PATH - SAMSHA 
   Pender DPI 
   PIPBHC Grant 
   PPW Grant 
   QRT Scholarship 
   RCC Grant 
   Roger Bacon Academy 
   RRS Grant 
   Save a Vet Now 
   Self Pay - 100% 
   Sliding Fee - Primary Care 
   Sliding Fee BH - 20% Discount 
   Sliding Fee BH - 40% Discount 
   Trilliam IPRS 
   Trillium Health Resources Accounts Payable 
   Trillium IPRS 
   U'Nique Community Scholarship 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

 

I would add that sample data as a manual table using power query and the enter data button pictured below:

 

helpme_0-1665059937676.png

 

Ensure that the headers are Commercial, Grant, Medicaid, Medicare, Uninsured or N/A then unpivot all columns.

 

You can then merge this into your original table using a left outer join and the [Credited Insur Carrier] as a the join key. Expand the columns and you'll have each insurance carrier and their category.

 

View solution in original post

5 REPLIES 5
danextian
Super User
Super User

Hi @anwilkins ,

 

In Power Query,  I would unpivot all these columns so they are in a form that will make it easy to do a lookup and do either:

  1.  Create a left outer join/merge in Power Query between this table of unpivoted columns and the fact table and not load the former or
  2. Load the former and create a relationship between the fact table and the table of unpivoted columns and use it as a dimension table.

Please refer to the sample M script below for the PQ approach:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hVZRb6M4EP4rVqV9WW1uc3unvWcgTZMHEg7SVtq9fXBhEqwzds6YVPn3NzYGDCG7UtVSbH/fzDffjPn+/SHgnFGRA1mQGAqWU1Y8fHoIQAuKf8MozPoVBSQoLlRoegJc+/hxJ8lW1I2y5yOqFAOFC9EmIpmmxyOJ9i/bFTlArR9+fEKuChTbAOW6nNBxTjJ6AVWT502EL9ZM1dpASs4E7fnN1jAiT8io8XkFZ6p0BUITeSQvoAEXahIcjxTPz1DuTGge75Ceyew3fNwfkvv0/XpQSA51bohXrKY1EvdBbSt6YgLIH1+XuP8pCWwcURCvO8KdyfCJaninV+JiGxSuUVCwohQNn8GP4QScU0GSZN9Dk3+a5fLLV7I10YVAcyk65P1ZMylqfN++uJKQN+AV1VBl++fV4qAYmqGpECXNLJNiGs3hkFoyqgqUhGPhhbxQC+3WHVYIJb0wqXCPiyC7YgKVjaCpKOq5ifc+O8bbHKVCwWUj9JWMy5rJnCFWBurCcjAoGOcrWsqjJZ2L78foVx0EHJkmMcZyAsvjobsYUd1RjJwWIMgq2faFQKeiihlWy9m790skqzNHN845TmJlgqJigtVaUS1VbZWeEmV5KSXH/+8gz3VRqNip7GQhCXrEg+69G6pG1O8s/9fJ3XPYXvXgetLbivZyj/BTyriStJghmeTziJY+S4bCjxKItk+7YB5zLnilb/AmYwzlSuprXvqYWXNGCU3VqYkn2kc2OE5VXbJzhzjbKw5TnVELpHI+qn337OCdbCjaDjv2Vz6OJG+qt6aeiDOhnjrokRegStoYhGfBNM4urxE8J/kiu44e8Ocyc85H0XBoYrBTgsgQtHUYCe6Dx9RNp673h3SHq6JrQDcYbvvhFTGiaTp1CRwD7Puv5RvCx8dc4lhIFBxBtTPUzHJAvVD4RMk3OwumR8maVoxfbcOQV8ou9hKLcfgy10NmXBvSz/t0Q+Ig6RB2USd9KZntBnNA2NvEzwgHUe7DOFVfad98CRpFmOvvtteGKdWOPltmoz9J4eTSwdoFaXrIbuA8edpxFTLhdGmr3Z3IqChKHP81iZDJKvAcp+3O7TrJxqr3N4WP71uF2OpluimM+1OosVtbF1gjIIGwtcA08RyORGyQ/RnrpJk4kUdhblCwVrB8JnZjywY5XKEWd7mdXybN2N8tGiMyjH2e9xmmrXfbDVmJvwvf5fO0bYf3+bzQKx3f/B5++34v4POT5OYuSBveJbRJ46gD6ZtkJMVL4JtvnKgDMGP1arxeIt0M2jTtb8CZSw27f5EBP5IEP11+Xy4/TI8vvHPtTxIcNuaeDOJsE3Tbh1UQhRmVyfZ2aZuEm2hsvGExeb2z8nd6mBvo/Xoa3cNM5QlDCe3HU5DjNVxdb/ek2Z3T5vuVUPMVSnby/Xa5U20x0m1Y56ww3l+DKUGiWEXV1bbRT7eGRtsvyw/mOzE3Xvv17j9/trvtbFqNhvpkFfveebdvbNTL4tUmRfrGb4OeflyOV5/t9+tfO/YfXkpDH07r+ON/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MEDICAID = _t, #" COMMERCIAL" = _t, MEDICARE = _t, UNINSURED = _t, #"N/A" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"MEDICAID", type text}, {" COMMERCIAL", type text}, {"MEDICARE", type text}, {"UNINSURED", type text}, {"N/A", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Category"}, {"Value", "Item"}}),
    #"Filtered Rows" = Table.SelectRows(#"Renamed Columns", each [Item] <> null and [Item] <> ""),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Category", Order.Ascending}})
in
    #"Sorted Rows"
  1.  

Mer










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you so much for replying! 

Anonymous
Not applicable

Hi,

 

I would add that sample data as a manual table using power query and the enter data button pictured below:

 

helpme_0-1665059937676.png

 

Ensure that the headers are Commercial, Grant, Medicaid, Medicare, Uninsured or N/A then unpivot all columns.

 

You can then merge this into your original table using a left outer join and the [Credited Insur Carrier] as a the join key. Expand the columns and you'll have each insurance carrier and their category.

 

Thanks again for the outstanding directions on how to create a table and link each insurance company to a category of medicare, medicaid, uninsured, etc. I'm curious if and how to structure a similar table. In this scenerio I have 21 medicaid insurance carriers who have different rules regarding the number of times a particular cpt code can be used. This differs for adults and children.

When I first built the report it had 17 IF statements that basically said,

Allowed Units =
IF(MERGE_BillingSummary[Current Insur Carrier] in {"AmeriHealth Caritas North Carolina", "AmeriHealth - Medicaid", "AmeriHealth - NCHC Medicaid"} && MERGE_BillingSummary[Patient Age] >= 21, 8,
IF(MERGE_BillingSummary[Current Insur Carrier] in {"AmeriHealth Caritas North Carolina", "AmeriHealth - Medicaid", "AmeriHealth - NCHC Medicaid"} && MERGE_BillingSummary[Patient Age] <= 20, 16,
 
I'm not sure the same table strucure will work since I am know looking at 2 tables so do you have any thoughts on how to set the rules according to the adult allowables then use an eles statement? Something like...
If  insurance = AmeriHealth Medicaid  & Age >= 21 then 8, else 16
 
Is is the entire sample data...the items at the bottom I am waiting on the allowed units and the reauthorization column is used to set a conditional formatting flag.
 
Insurance CarrierAllowed Usage of a CPT Code For AdultsAllowed Usage of a CPT Code For KidsReauthorization Alert
AmeriHealth - Medicaid8164
Cardinal Innovations Healthcare8164
Cardinal Innovations Medicaid8164
Healthy Blue - Medicaid8124
ASOUD-Trillium IPRS12244
Trillium IPRS12244
Eastpointe - IPRS16244
Eastpointe - Medicaid16244
WellCare - Medicaid20204
Carolina Complete Health - Medicaid24244
Trillium Medicaid24244
Alliance - Medicaid52524
UHC Community Plan - Medicaid99999999 
UHC Community Plan - NCHC Medicaid99999999 
AmeriHealth - NCHC Medicaid   
Carolina Complete - NCHC Medicaid   
Healthy Blue - NCHC Medicaid   
NC Healthchoice   
Vaya Health Medicaid   
WellCare - NCHC Medicaid   
 
 Thanks again for any further insight you have!
Ashley

This is PERFECT!!!!!! Thanks you so much!!!!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.