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
REKLP
Helper I
Helper I

Use previous data to fill in blanks in table

I have gaps between my data. 

1.png

 

I'd like to fill them in with the previous data, for example.

3.png

 

I tried using an if statement (shown below), but it doesn't seem to work because there's just no data there.  I don't want to put a zero either.

 

I also tried putting zero + the calculated measure, but that doesn't work either.

 

 

CountOfRowsInTable = 
IF(
    ISBLANK(
        CALCULATE (
            SUM( AppendedTables[Active] ),
            FILTER (
                ALLEXCEPT(AppendedTables, v_infohr_region[ED_REGION], v_infohr_plant[plant]),
                AppendedTables[Year-Month] <= MAX ( AppendedTables[Year-Month] )
            )
        )
    ),
    CALCULATE (
            SUM( AppendedTables[Active] ),FILTER(AppendedTables,0=0)
        ),
    CALCULATE (
            SUM( AppendedTables[Active] ),
            FILTER (
                ALLEXCEPT(AppendedTables, v_infohr_region[ED_REGION], v_infohr_plant[plant]),
                AppendedTables[Year-Month] <= MAX ( AppendedTables[Year-Month] )
            )
    )
)
1 ACCEPTED SOLUTION

@REKLP

 

m_ActiveEmployees_V2 = CALCULATE (
    SUM( ActiveEmployee[Active] );
    FILTER (
        ALL(MonthTable);
        MonthTable[Year-Month] <= MAX ( MonthTable[Year-Month] )
    )
)

View solution in original post

25 REPLIES 25

Hi @REKLP

 

I ran a quick test and it does seem to work, unless I've misunderstood what you're trying to achieve. I am using a simple measure instead of yours so the issue might be there but the pattern should be fine.

What the code does is actually reenact what you have in the matrix within the measure. If the result for [YourMeasure] is blank in the current row of the matrix, the measure takes all [Year-Month] previous to the current [Year-Month] and finds the last one for which the result of [YourMeasure] is non-blank.       

@AlB, Do you mind uploading the PBIX so I can take a look please?

Anonymous
Not applicable

can fill in null values in PQ relatively easy.  If you upload some data I'll take a look

@Anonymous, Thank you for the offer, but I'd rather not at this time due to the information in the pbix.

 

Do you have a sample/link of what you propose?

Anonymous
Not applicable

Take a look at the attached PBIX file and step through the applied steps on the right.  There are two ways in there a simpler way and a  little more complex way, but nothing to terrible 🙂

 

File:

https://1drv.ms/f/s!AoQIGRpzoxRH-kGIakeyIX57LUqW

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.