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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Dataman9000
Regular Visitor

Create new table from two tables via DAX or M

Hi,

 

I have a composite model with a lot of tables.  I need to create a new fact table from a list of tables I have via Dax or M.  Below is a an example of my table structure, can someone please provide the basic codes to get me started?

 

Fact Table

AccountCost CenterValue
110040
210027
310057
410068
51004
610050
120052
220063
320025
420013
520033
620027

 

Dim Table

AccountGroup1Group2
1ax
2ax
3ax
4bx
5by
6by

 

New Table based on conditions:  Combine Fact table with Dim table when Dim table Group1 is "a".

AccountCost CentrValueGroup1Group2
110040ax
210027ax
310057ax
120052ax
220063ax
320025ax

 

Thank you in advance!

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Dataman9000  you can do this

smpa01_0-1715700585783.png

 

 

GENERATE('fact', var one = 'fact'[Account] return SELECTCOLUMNS(FILTER(dim, dim[Group1]="a"&&dim[Account]=one),[Group1],[Group2]))
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

6 REPLIES 6
smpa01
Super User
Super User

@Dataman9000  you can do this

smpa01_0-1715700585783.png

 

 

GENERATE('fact', var one = 'fact'[Account] return SELECTCOLUMNS(FILTER(dim, dim[Group1]="a"&&dim[Account]=one),[Group1],[Group2]))
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

TY - this is the solution I am looking for.

ray_aramburo
Super User
Super User

Then you will need to provide a SQL-like query where you create the join and specify the group with a Where clause.





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





I don't have access to the source, that's why I need to do it using Dax or M.

ray_aramburo
Super User
Super User

1. Create a duplicate/reference of the Dim Table and filter it for group 1 = "a"

ray_aramburo_0-1715694167161.png

 

2. Go to fact table, merge queries and select account columns, and click Ok:

ray_aramburo_1-1715694205049.png

ray_aramburo_2-1715694254601.png

3. Expand to extract Group 1 and Group 2 columns

ray_aramburo_3-1715694341787.png

4. You're done 🙂

 

If you only need for Group a data to be on the fact table, then dismiss step 1 and filter out after you have merged as Step 4.

You can see my file as example and leverage from it.

 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





Hi Ray,

 

Thank you for your response, but I need a solution from "Creat table".  I am using a SSAS cube, so those options are not availble in the model.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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