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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
singh_gagan30
Helper I
Helper I

Make a table out of an existing table

Hi All,

 

I have a table with column cycle and year data given below:

CYCLE     YEAR

201912   2019

201912   2020

Actuals   2019

 

I want an output table as:

CYCLE   YEAR   CYCLE-1   YEAR-1

201912  2019   201912     2020

201912  2019   Actuals     2019

201912  2020   201912     2019

201912  2020   Actuals     2019

Actuals  2019   201912     2019

Actuals  2019   201912     2020

 

TIA

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please let me know.
 
Best Regards
Maggie
ToddChitt
Super User
Super User

This looks to be a cartesian (CROSS) join between the entire table and the first two rows.

Try this:

1-In Power Query, duplicate or Reference the original table so you have a copy of it. We'll call this the COPY and the ORIGINAL

2-On the COPY, apply a Filter step to filter out the value of "Actuals" in the first column, so it should now have 2 rows

3-Apply and Close to bring the two tables into the model.

4-Create the result table with the following DAX statement:

 

RESULT = CROSSJOIN(ORIGINAL, COPY)

 

 

 

This solution uses BOTH Power Query AND DAX as you cannot do a CROSS JOIN in Power Query, and you use PowerQuery to do the filtering. I suppose you could create the COPY table with a FILTER statement in DAX:

COPY = FILTER(ORIGINAL, [Cycle] <> "Actuals")

 

Hope this helps

 

But there will bemore data which will be appended below. I guess than hard coding "Actuals" would fail in that case.

Hi @singh_gagan30 

As tested, rajulshah's suggestion works on my side.

Capture2.JPG

Could you show me the problem when implementing the method on your model?

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

rajulshah
Super User
Super User

Hello @singh_gagan30,

Please try following dax query:

Cycle CrossJoin = 
VAR CycleCrossJoinDummy = SELECTCOLUMNS(Cycles,"Cycle Name",Cycles[CYCLE],"Cycle Year",Cycles[YEAR])
VAR CrossJoinTable = CROSSJOIN(CycleCrossJoinDummy,Cycles)
RETURN FILTER(CrossJoinTable,[Cycle Name]&[Cycle Year]<>[CYCLE]&[YEAR])

Hope this helps. 

Hi,

 

I guess aftre using this query for forming a new table has went into an infinte loop.

 

Regards

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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