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
AmandaL
Regular Visitor

Adding Missing Rows - need help!

Hello,
I'm trying to create a summarized table in DAX that extracts customer info from my main data table and adds in the missing rows for months based on the last date in a different calculated month column. I'll be very happy if anyone can solve this for me.

 

Here is a simplified data extract, also showing where the data in the columns has come from.  The last column ("alternative") is conditional based on the flag column (shows a different date if the flag = 1) - see last row.

Source :Orig DataOrig DataDAX ColumnPQ ColumnDAX Column
Column Name :CompanyIDFlagActive MonthAlternative Active Month
Data :Company A12340Jan-21Jan-21
 Company A12340Feb-21Feb-21
 Company A12340Mar-21Mar-21
 Company A12340Apr-21Apr-21
 Company A12340May-21May-21
 Company A12340Jun-21Jun-21
 Company A12340Jul-21Jul-21
 Company A12341Aug-21Oct-21

 

I'm trying to insert/create the "missing" rows of September and October ie. fill in the gap between the last "active month" of August and the last "alternative active month" of October. This is so I can create visuals that will recognise the flag as being active in August,  September AND October. I've been trying ADDMISSINGITEMS with SUMMARIZEDCOLUMNS but cannot get it to give the answer I need. I'm looking to ideally update just the existing "active month" column, but if instead I need to create a third date column that actually does the job that would be fine as the data set is not enormous :

CompanyIDFlagActive MonthAlternative Active MonthNEW Month Column
Company A12340Jan-21Jan-21Jan-21
Company A12340Feb-21Feb-21Feb-21
Company A12340Mar-21Mar-21Mar-21
Company A12340Apr-21Apr-21Apr-21
Company A12340May-21May-21May-21
Company A12340Jun-21Jun-21Jun-21
Company A12340Jul-21Jul-21Jul-21
Company A12341Aug-21Oct-21Aug-21
Company A12341Sep-21Oct-21Sep-21
Company A12341Oct-21Oct-21Oct-21

 

Thank-you

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can't do this in the same table with DAX. You have to define a new one.

 

Assuming your month columns are date type, you can define a new calculated table like this:

 

NewTable= 
    GENERATE (
        Orig,
        VAR N = DATEDIFF ( Orig[Active Month], Orig[Alternative Active Month], MONTH )
        RETURN
            SELECTCOLUMNS (
                GENERATESERIES ( 0, N ),
                "New Month", EOMONTH ( Orig[Active Month], [Value] )
            )
    )

 

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

You can't do this in the same table with DAX. You have to define a new one.

 

Assuming your month columns are date type, you can define a new calculated table like this:

 

NewTable= 
    GENERATE (
        Orig,
        VAR N = DATEDIFF ( Orig[Active Month], Orig[Alternative Active Month], MONTH )
        RETURN
            SELECTCOLUMNS (
                GENERATESERIES ( 0, N ),
                "New Month", EOMONTH ( Orig[Active Month], [Value] )
            )
    )

 

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.