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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PrathSable
Advocate II
Advocate II

DAX Column for grouping values from same column

Hi,

 

Need help on getting a tricky problem resolved on the data - 

 

I have the below table combining 4 columns - ID, Name, Scheme & Volume

 

What I need to do is from the Scheme which has multiple schemes, I need to create a calculated column that will automatically group the schemes and sum up the cost - it might be a permutation/combination methodology, but I am trying to work how I can achieve this - I tried summarise, earlier, Treatas etc and 

 

INPUT:

 

IDNameSchemeVolume
E2334545ABC holdingAAA123232
E2334545ABC holdingBBB23424
E2334545ABC holdingCCC345345
E2334545ABC holdingDDD3454345
E2334545ABC holdingXXX3454345
E2334545ABC holdingWWW3454345
E567432ABC holdingSSA354345
E567432ABC holdingWDA546
E567432ABC holdingAAA56
E567432ABC holdingSAD46756
R57655668Real EstateGDC46766
R57655668Real EstateSSA575857
R57655668Real EstateSAD87586
R57655668Real EstateCCC8578776
R57655668Real EstateDSA544534
H7656555Limited CoRED75866
H7656555Limited CoFFF35345
H7656555Limited CoXXX3535
H7656555Limited CoWWW552
T345345334Private InstituteYYY34534
T345345334Private InstituteVBN7654
T345345334Private InstituteGDC6365
T345345334Private InstituteSAW535
T345345334Private InstituteAAA5252
T345345334Private InstituteCCC52425
T345345334Private InstituteFFF5252

 

OUTPUT:

 

Scheme combinationTotal Volume
AAA-BBB             1,57,216
SSA-AAA          10,58,742
WWW-GDC          35,13,280

 

So basically it should group the combinations from the Scheme & combine the volumes together

Is there any way to achieve this? I am really stuck on this session & would really appreciate any help that comes through.

 

Thanks

Prath

 

@Admin @amitchandak 

9 REPLIES 9
johnt75
Super User
Super User

If you have something like

Scheme CombinationScheme
AAA-BBBAAA
AAA-BBBBBB
WWW-GDC

WWW

WWW-GDC

GDC

with a many-to-many relationship from this table to your scheme table, then your total volume measure could be something like

Total Volume = SUMX( 'Scheme Combination Table',
SUMX( RELATEDTABLE( 'Schemes' ), 'Schemes'[Volume] )
)

That's the main problem I do not have a scheme combination 😪

That is what I am looking to create. 

Are you looking to combine every scheme with every other scheme ?

What I am trying to do is work out whats the combinations of the schemes and then which accounts will fall under that combination and what volumes can I expect if I combine both those schemes together to sell to the account. 

what's the logic behind a scheme combination? what determines whether a scheme combination is valid or real ?

Exactly, what I need to basically do is - try to find out based on how I combine the schemes which combination suits best for a customer from where I can get a good volume (here volume is the revenue) Like whether for a customer ABC holding which scheme combination works (AAA-BBB or XXX-WWW) And vice verse if I combine the schemes SAD-YYY so I have 2 customers CCC-YYY so I have 2 customers there but that combination gives me highest revenue out. 

 

It's similar to =+SUMIFS that excel uses

 

Also, I can bring n same column twice in there like Scheme 1, Scheme 2 to figure out whether that can work.

 

I know this is a little tricky. Thank you very much in advance for understanding this.

You could generate a table with every possible combination with something like

Combination Table =
ADDCOLUMNS( FILTER(
GENERATE( VALUES( 'Table'[Scheme] ),
SELECTCOLUMNS( CALCULATETABLE( VALUES( 'Table'[Scheme] ), ALL() ),
"2nd scheme", 'Table'[Scheme]
)
),
[2nd scheme] <> [Scheme]
),
"Combination name", [Scheme] & "-" & [2nd scheme]
)

but bear in mind that this will include both "AAA-BBB" and "BBB-AAA" variations of the combination.

Once you have this table in place create relationships from both scheme columns to 'Table'[Scheme].

Now you can create measures to get total values for a scheme combination with something like

Scheme Combination Total =
CALCULATE( SUM( 'Table'[Volume] ), USERELATIONSHIP( 'Table'[Scheme], 'Combination Table'[Scheme]) )
+ CALCULATE (
SUM( 'Table'[Volume] ), USERELATIONSHIP( 'Table'[Scheme], 'Combination Table'[2nd scheme] )
)

 

 

PrathSable
Advocate II
Advocate II

Tried that doesn't work, can you share a example of it please?

johnt75
Super User
Super User

How about a mapping table so that each Scheme Combination had a row for each Scheme, link the Scheme column from the new table to the Scheme column in your data in a many-to-many relationship. I think that's the only way to define which schemes fit into which combinations

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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