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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DaveHepler
Frequent Visitor

Split rows using a column, and divide values.

I have used other means to accomplish this same task but I'm running into issues with RLS and the inactive relationships.   It seems to the only way for RLS to work would be to split my rows.   Below is some example data.   I have sales data with splits by salesperson.  I can write DAX to do whatever I need with this using a relationship for a salesperson dimension table and USERELATIONSHIP for an inactive relationship for salesperson 2.   No issues there...  The report is done and a lot of work on measures is working great.  Again the RLS is what kills it.  I didn't realize that when implementing RLS it would not allow the inactive relationship I need to make salesperson 2 work.   I need to be able to use RLS to filter this table by salesperson 1 AND 2... while still having  My thought is to actually split the rows.   

 

Opportunity Table

IDamountsalesperson 1salesperson 2split type
11000AB70-30
22000B 100
33000CA0-100
44000DA50-50
55000D  

 

Desired New/revised Opportunity table.  

IDamountsalesperson
1700A
1300B
22000B
30C
33000A
42000D
42000A
55000D

 

This way I could use one relationship and RLS would work.  My measures will need to be tweaked a bit but if anything they will be less complicated.   The problem is they dont always enter values for the splits.  I just used a simple DAX switch to sanitize it but I'm somewhat convinced I need to split these rows out in Power Query and I'm not as good there.  I can "fix" the split column just fine.  I've used "unpivot columns" for a similar task but I cant wrap my head around how I would Unpivot based on the split type and actually do the math to the amount column at the same time.

 

I also have a Salesperson dimension table.

Salespersons

IDSalesperson
AAlice
BBob
CCharlie
DDave

 

The actual end goal is something like this.  RLS is set to filter salesperson.  In this case "Bob" is logged in.   

Visual in Bi

SalespersonAmount
Bob2300

 

With my current set up...  if I use RLS on the opportunity to "Bob" I need it to be something like [Sales_Person_1__c] = "B" || [Sales_Person_2__c] = "B"  The problem is this also allows the other part of the split in.   Opportunity 1 was split between Alice and Bob.   So it shows something like this.

 

SalespersonAmount
Bill2300
Alice700

 

Okay.. not what I need so then I try to set RLS on the Salespersons table above.  That table has two relationships though... because I have two salesperson columns in opportunity.   I have one active and one intactive and then USERELATIONSHIP for the intactive.   Hopefully this makes sense.   Its a bit complicated, at least to me.   I really need direction on either getting RLS to work or splitting out those opportunities like I mentioned at the start. 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

new query in dax

NewTable = SELECTCOLUMNS(GENERATE('Table',VAR _p=SUBSTITUTE(IF('Table'[split type]="",100,'Table'[split type]),"-","|") RETURN ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH(_p)),"@amt",'Table'[amount]*VALUE(0&PATHITEM(_p,[Value]))/100,"@SalesPerson",IF([Value]=1,'Table'[salesperson 1],'Table'[salesperson 2]))),"ID",[ID],"Amount",[@amt],"SalesPerson",[@SalesPerson])

wdx223_Daniel_1-1671159345485.png

 

or transform it in M

= #table({"ID","Amount","Salesperson"},List.TransformMany(Table.ToRows(#"Changed Type"),each let a=Text.Split(_{4},"-") in if List.Count(a)=1 then {{_{1},_{2}}} else List.Transform(List.Positions(a),(x)=>{_{1}*Number.From(a{x})/100,_{x+2}}),(x,y)=>{x{0}}&y))

wdx223_Daniel_0-1671159327314.png

 

View solution in original post

1 REPLY 1
wdx223_Daniel
Super User
Super User

new query in dax

NewTable = SELECTCOLUMNS(GENERATE('Table',VAR _p=SUBSTITUTE(IF('Table'[split type]="",100,'Table'[split type]),"-","|") RETURN ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH(_p)),"@amt",'Table'[amount]*VALUE(0&PATHITEM(_p,[Value]))/100,"@SalesPerson",IF([Value]=1,'Table'[salesperson 1],'Table'[salesperson 2]))),"ID",[ID],"Amount",[@amt],"SalesPerson",[@SalesPerson])

wdx223_Daniel_1-1671159345485.png

 

or transform it in M

= #table({"ID","Amount","Salesperson"},List.TransformMany(Table.ToRows(#"Changed Type"),each let a=Text.Split(_{4},"-") in if List.Count(a)=1 then {{_{1},_{2}}} else List.Transform(List.Positions(a),(x)=>{_{1}*Number.From(a{x})/100,_{x+2}}),(x,y)=>{x{0}}&y))

wdx223_Daniel_0-1671159327314.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors