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
Erf19
Frequent Visitor

CalculateTable - Create rows with two columns and their distinct values

Hello,

 

I have a table like this:

PersonWeek NumberValue

A

1100
A250
A320
B150
B310
C115
C255

 

What I want is to take the unique values for Person and the unique values for Date and make a row for each unique pair, to create a new table like this:

PersonWeek Number
A1
A2
A3
B1
B2
B3
C1
C2
C3

 

That way, where for example person B doesn't have an entry for week 2, I can add a lookup column on the new table and say the value is 0.

 

Is there a formula to create this new table? I am thinking union, product, summarize.... not sure!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Erf19 - Try:

Table =
  GENERATE(
    DISTINCT('Table'[Person]),
    DISTINCT('Table'[Week])
  )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Erf19 - Try:

Table =
  GENERATE(
    DISTINCT('Table'[Person]),
    DISTINCT('Table'[Week])
  )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Erf19 , Try a new Table like 

union(
addcolumns(except(crossjoin(distinct(Table[Person]),distinct(Table[Week])), selectcolumn(Table,"Person",[Person],"Week",[Week])),"Number Value",0),
Table)

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.