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
markjdm_17
New Member

Generate Series Based on Table (2 Columns)

Hi Team,

 

 I am looking at generating a series of columns based on a table as per below. 

 

Table: 

Trading NameOpen DateEnd Date
Centre 12/05/20202/08/2020
Centre 224/08/202024/11/2020

 

Results Table: 

Trading NameDateMonth
Centre 12/05/20201
Centre 12/06/20202
Centre 12/07/20203
Centre 12/08/20204
Centre 224/08/20201
Centre 224/09/20202
Centre 224/10/20203
Centre 224/11/20204

 

Now I was able to generate the table using the below guide but can't figure out how to add the series (Month) column. 

 

New Table =
SELECTCOLUMNS(
   FILTER(
         GENERATE(
                   'Table',
                   GENERATESERIES(MIN('Table'[Open Date]), MIN('Table'[End Date]), 1)
          ),
         [Value] >= [Open Date]
         && [Value] <= [End Date]
   ),
  "Label", [Trading Name],
   "Value", [Value]
)

 

https://community.powerbi.com/t5/Desktop/Generate-series-of-numbers-based-on-other-table-values/m-p/...

 

Cheers,
Mark

1 ACCEPTED SOLUTION

Thanks for all the responses. I was able to figure this out by just generating the series with the above dax query I mentioned.  I then just created a rank column to get the sequence of dates. 

 

Rank =
VAR D = 'Result Table'[Value]
VAR C = 'Result Table'[Label]
RETURN
CALCULATE(
RANK.EQ(D, 'Result Table'[Value], ASC),
FILTER(ALL('Result Table'), 'Result Table'[Label] = C)
)

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@markjdm_17 - If I am understanding this correctly, try this:

New Table =
SELECTCOLUMNS(
   FILTER(
         GENERATE(
                   'Table',
                   ADDCOLUMNS(
                     GENERATESERIES(MIN('Table'[Open Date]), MIN('Table'[End Date]), 1),
                     "Month",MONTH([Value])
                   )
          ),
         [Value] >= [Open Date]
         && [Value] <= [End Date]
   ),
  "Label", [Trading Name],
   "Value", [Value]
)

@ 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

Thanks for all the responses. I was able to figure this out by just generating the series with the above dax query I mentioned.  I then just created a rank column to get the sequence of dates. 

 

Rank =
VAR D = 'Result Table'[Value]
VAR C = 'Result Table'[Label]
RETURN
CALCULATE(
RANK.EQ(D, 'Result Table'[Value], ASC),
FILTER(ALL('Result Table'), 'Result Table'[Label] = C)
)

Hi @markjdm_17 ,

 

Glad to hear that. Please accept your reply as a solution so that people who may have the same question can get the solution directly. Your contribution is highly appreciated.

 

 

Best Regards,

Icey

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.