Forum Discussion
demultiplying rows on a table based on a specific filtered value
Hello,
The question is not easy to formulate, so, let's take an example :
Lets imagine that I have these 2 tables :
DIMTABLE :
| Service_CD | Application_CD |
| 10076 | 6832 |
| 10076 | 10314 |
| 10076 | 10337 |
| 10078 | 5330 |
| 10078 | 6832 |
AND ANOTHER TABLE : FACT_TABLE :
| Application_CD | DATE | VAL1 | INF | DESC |
| 6832 | 01.oct.24 | 1 | a | fds |
| 6832 | 02.oct.24 | 2 | b | sf |
| 6832 | 03.oct.24 | 3 | c | sfddf |
| 5330 | 02.oct.24 | 4 | a | sgfsd |
| 5330 | 03.oct.24 | 5 | b | sf |
| 5330 | 01.oct.24 | 6 | c | sdf |
| 10337 | 02.oct.24 | 7 | a | fds |
| 10337 | 03.oct.24 | 8 | b | fs |
| 10337 | 01.oct.24 | 9 | c | fds |
| 10314 | 02.oct.24 | 10 | a | sdf |
| 10314 | 03.oct.24 | 11 | b | dfssfd |
| 10314 | 01.oct.24 | 12 | c | sdfsdfsd |
I need to mix these 2 tables (Sort of Crossjoin ?) and get the below result table :
| Service_CD | Application_CD | DATE | VAL1 | INF | DESC |
| 10076 | 6832 | 01.oct.24 | 1 | a | fds |
| 10076 | 6832 | 02.oct.24 | 2 | b | sf |
| 10076 | 6832 | 03.oct.24 | 3 | c | sfddf |
| 10076 | 10314 | 02.oct.24 | 10 | a | sdf |
| 10076 | 10314 | 03.oct.24 | 11 | b | dfssfd |
| 10076 | 10314 | 01.oct.24 | 12 | c | sdfsdfsd |
| 10076 | 10337 | 02.oct.24 | 7 | a | fds |
| 10076 | 10337 | 03.oct.24 | 8 | b | fs |
| 10076 | 10337 | 01.oct.24 | 9 | c | fds |
| 10078 | 5330 | 02.oct.24 | 4 | a | sgfsd |
| 10078 | 5330 | 03.oct.24 | 5 | b | sf |
| 10078 | 5330 | 01.oct.24 | 6 | c | sdf |
| 10078 | 6832 | 01.oct.24 | 1 | a | fds |
| 10078 | 6832 | 02.oct.24 | 2 | b | sf |
| 10078 | 6832 | 03.oct.24 | 3 | c | sfddf |
If it is possible to do that in an easy way with DAX, it would help a lot,
Thanks,
Roland.
- Anonymous1 year ago
Hi Cobalt2234
Here are 2 workarounds for your reference:
1:
Click Transform data to go to power query.
First of all, Duplicate the DIMTABLE(Another table will do the same).
Click the Merge Queries in the Home pane:
Select the Application_CD columns and click OK.
Expand the table:
The result is as follow:
2:
Add a calculated table:
Table = SELECTCOLUMNS( FILTER( CROSSJOIN( 'DIMTABLE', 'FACT_TABLE' ), 'DIMTABLE'[Application_CD] = 'FACT_TABLE'[Application_CD] ), 'DIMTABLE'[Service_CD], 'FACT_TABLE'[Application_CD], 'FACT_TABLE'[DATE], 'FACT_TABLE'[VAL1], 'FACT_TABLE'[INF], 'FACT_TABLE'[DESC] )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- 123abc
Community Champion
If you prefer DAX, you can use a calculated table to achieve the result. Here's the DAX formula to create a new table that combines both:
ResultTable =SELECTCOLUMNS(FILTER(CROSSJOIN(DIMTABLE, FACT_TABLE),DIMTABLE[Application_CD] = FACT_TABLE[Application_CD]),"Service_CD", DIMTABLE[Service_CD],"Application_CD", DIMTABLE[Application_CD],"DATE", FACT_TABLE[DATE],"VAL1", FACT_TABLE[VAL1],"INF", FACT_TABLE[INF],"DESC", FACT_TABLE[DESC])Final Output
After applying either method, you’ll get the combined table as desired:
Service_CD Application_CD DATE VAL1 INF DESC10076 6832 01.oct.24 1 a fds 10076 6832 02.oct.24 2 b sf 10076 6832 03.oct.24 3 c sfddf ... ... ... ... ... ... - Cobalt2234Regular Visitor
Thanks for this Dax solution.
I decided to use the Power Query solution above that I thought was better for performance issue, the real table is quite big.
But anyway, I'll keep also your solution provided in my notes.
Thanks a lot for your time and help provided.
- AnonymousNot applicable
Hi Cobalt2234
Here are 2 workarounds for your reference:
1:
Click Transform data to go to power query.
First of all, Duplicate the DIMTABLE(Another table will do the same).
Click the Merge Queries in the Home pane:
Select the Application_CD columns and click OK.
Expand the table:
The result is as follow:
2:
Add a calculated table:
Table = SELECTCOLUMNS( FILTER( CROSSJOIN( 'DIMTABLE', 'FACT_TABLE' ), 'DIMTABLE'[Application_CD] = 'FACT_TABLE'[Application_CD] ), 'DIMTABLE'[Service_CD], 'FACT_TABLE'[Application_CD], 'FACT_TABLE'[DATE], 'FACT_TABLE'[VAL1], 'FACT_TABLE'[INF], 'FACT_TABLE'[DESC] )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- Cobalt2234Regular Visitor
Thank you so much for the Power Query Workaround.
I used it and it is working perfectly.
I did not used the dax solution (for now), but I'll keep it in mind.