cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sakshi Regular Visitor
Regular Visitor

To display repeated rows using DAX

Hello All

 

I am a newbie in DAX. Need to figure out the implementation of looping concept.

 

I have a single table which has columns as

  • Start-Date 
  • No. of Repeating days
  • Assigned Value

Now I need to display a single tabular visualization in Power BI Report displaying all the dates with their assigned values. 

Let's suppose Start-Date = "01 Aug 2017" and No. of Repeating Days =3 for that row having Assigned Value = 4. Then, the table should be like:

 

Date                        Assigned Value

01 Aug 2017                   4

02 Aug 2017                   4

03 Aug 2017                   4

 

Could someone please direct me how to achieve this through DAX or through Power BI features.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
v-ljerr-msft Super Contributor
Super Contributor

Re: To display repeated rows using DAX

Hi @Sakshi,

 

Based on my test, you should be able to follow steps below to get your expected result in Power BI. Smiley Happy

 

1. In Query Editor, use the formula(M) below to add a new custom column called "End-Date" under Add Column tab > Custom Column.

= Date.AddDays([#"Start-Date"],[No. of Repeating days]-1)

endate.PNG

 

2. Use the formula(M) below to add another custom column called "Date".

= {Number.From([#"Start-Date"])..Number.From([#"End-Date"])}

date.PNG

 

3. Expand to New Rows for Date column.

expandtorows.PNG

 

Then you will get a table like below.

t1.PNG

 

4. Last, you will get your expected result by changing Data Type to Date for "Date" column.

datatype.PNG

 

5. Click "Close&Apply" to apply the changes.

apply.PNG

 

Regards

1 REPLY 1
Highlighted
v-ljerr-msft Super Contributor
Super Contributor

Re: To display repeated rows using DAX

Hi @Sakshi,

 

Based on my test, you should be able to follow steps below to get your expected result in Power BI. Smiley Happy

 

1. In Query Editor, use the formula(M) below to add a new custom column called "End-Date" under Add Column tab > Custom Column.

= Date.AddDays([#"Start-Date"],[No. of Repeating days]-1)

endate.PNG

 

2. Use the formula(M) below to add another custom column called "Date".

= {Number.From([#"Start-Date"])..Number.From([#"End-Date"])}

date.PNG

 

3. Expand to New Rows for Date column.

expandtorows.PNG

 

Then you will get a table like below.

t1.PNG

 

4. Last, you will get your expected result by changing Data Type to Date for "Date" column.

datatype.PNG

 

5. Click "Close&Apply" to apply the changes.

apply.PNG

 

Regards

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 42 members 1,183 guests
Please welcome our newest community members: