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
Anonymous
Not applicable

Adding dates to existing rows in table

I currently have a table with the following:

ID

Category

Failure Rate

1

A

0.5

2

B

0.2

3

C

0.1

 

I need to add a date range of month-year for each row on the table so it would become

ID

Category

Failure Rate

Date

1

A

0.5

Jan-17

1

A

0.5

Feb-17

1

A

0.5

March-17

1

A

0.5

Apr-17

1

A

0.5

May-17

1

A

0.5

Jun-17

1

A

0.5

Jul-17

1

A

0.5

Aug-17

1

A

0.5

Sept-17

1

A

0.5

Oct-17

1

A

0.5

Nov-17

1

A

0.5

Dec-17

2

B

0.2

Jan-17

2

B

0.2

Feb-17

2

B

0.2

March-17

2

B

0.2

Apr-17

2

B

0.2

May-17

2

B

0.2

Jun-17

2

B

0.2

Jul-17

2

B

0.2

Aug-17

2

B

0.2

Sept-17

2

B

0.2

Oct-17

2

B

0.2

Nov-17

2

B

0.2

Dec-17

3

C

0.1

Jan-17

3

C

0.1

Feb-17

3

C

0.1

March-17

3

C

0.1

Apr-17

3

C

0.1

May-17

3

C

0.1

Jun-17

3

C

0.1

Jul-17

3

C

0.1

Aug-17

3

C

0.1

Sept-17

3

C

0.1

Oct-17

3

C

0.1

Nov-17

3

C

0.1

Dec-17


The reason for the above is to achieve something with the following pseudo code:

IF DATE is BETWEEN Jan-17 and Dec-19 THEN DIVIDE failure rate by 24
ELSE IF DATE is BETWEEN Dec-19 to Dec-21 THEN DIVIDE failure rate by 12

Any ideas?

1 ACCEPTED SOLUTION

hi, @Anonymous 

If so, try this formula

Table= var _datetable=FILTER(CALENDAR("2017-01-01","2017-12-31"),DAY([Date])=1) return

GENERATE(Basic,SELECTCOLUMNS(_datetable,"Mon-year",FORMAT([Date],"MMM-YYYY")))

https://docs.microsoft.com/en-us/dax/pre-defined-date-and-time-formats-for-the-format-function

If so, [Mon-year] is a text type, ("Jan-2017" not a date format).

I would suggest you use above formula to create the table and change the format in modeling. In this case, it still the date type.

 

 

Best Regards,

Lin

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

View solution in original post

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

You could just use this formula to create a "New Table"

Table = GENERATE(Basic,FILTER(CALENDAR("2017-01-01","2017-12-31"),DAY([Date])=1))

Result:

1.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Lin,

So I've created a new table and used your formula. I think I'm almost there but how do I get the syntax of the date to appear "Jan-2017" so "MMM-YYYY"


hi, @Anonymous 

If so, try this formula

Table= var _datetable=FILTER(CALENDAR("2017-01-01","2017-12-31"),DAY([Date])=1) return

GENERATE(Basic,SELECTCOLUMNS(_datetable,"Mon-year",FORMAT([Date],"MMM-YYYY")))

https://docs.microsoft.com/en-us/dax/pre-defined-date-and-time-formats-for-the-format-function

If so, [Mon-year] is a text type, ("Jan-2017" not a date format).

I would suggest you use above formula to create the table and change the format in modeling. In this case, it still the date type.

 

 

Best Regards,

Lin

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

Hello Lin,

 

maybe you could help me as well. I have a similar problem, but I have a specific year that needs to be add to every row. That's what I have:

Name201820192020
A4542768
B3113432
C457843
D424665

 

And that's what I need:

 

NameTotalYear
A452018
B312018
C452018
D422018
A422019
B132019
C782019
D462019
A7682020
B4322020
C432020
D652020

 

It'd be great if it worked automatically.

 

Thanks,

Dina

Anonymous
Not applicable

Worked perfectly, you're a star Lin!

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.