Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JosemaMz
New Member

Fill next blank value based on latest value

Hello everyone!
I'm working on a dashboard where complaints in various centers are analyzed. I need an indicator that results from dividing complaints by the center's occupancy, all grouped by quarter. However, occupancy data is renewed quarterly, so to start analyzing complaint data without having the occupancy data yet, I need to obtain the data from the previous quarter. In this case, this post is made on April 18, the first quarter of 2024, and the occupancy data for this moment is blank, so I would need the data from the last quarter of 2023.

I have used this formula, but it returns the highest occupancy data, not the data from the last quarter:

UltimaOcupacion =
VAR MaxFecha = LASTNONBLANK('Tabla Intermedia Gest/Ocup'[Año/cuatri], 'Tabla Intermedia Gest/Ocup'[Año/cuatri])
VAR LastOccupation =
    CALCULATE(
        LASTNONBLANK('OCUPACION'[Ocupacion], 1),
        FILTER(
            ALL('OCUPACION'),
            'OCUPACION'[Año/cuatri] = MaxFecha &&
            'OCUPACION'[Centro] = SELECTEDVALUE('CENTROS'[Centro])
        )
    )
VAR PreviousOccupation =
    CALCULATE(
        LASTNONBLANK('OCUPACION'[Ocupacion], 1),
        FILTER(
            ALL('OCUPACION'),
            'OCUPACION'[Año/cuatri] < MaxFecha &&
            'OCUPACION'[Centro] = SELECTEDVALUE('CENTROS'[Centro])
        )
    )
RETURN
    IF(
        ISBLANK(LastOccupation),
        PreviousOccupation,
        LastOccupation
    )
 
 
 
 
Año/cuatri means year/quarter = 2023 1Q, 2023 2Q...
 
JosemaMz_0-1713451373774.png

 

CentroQS      Ocupación    Goal Ocupacion      UltimaOcupacion  Año/cuatri 
Centro 1   162642642642023 1º Cuatrimestre
Centro 1   102752752752023 2º Cuatrimestre
Centro 1   122782782782023 3º Cuatrimestre
Centro 1   2 2782782024 1º Cuatrimestre
Centro 2      182032032032023 1º Cuatrimestre
Centro 292032032032023 2º Cuatrimestre
Centro 291941941942023 3º Cuatrimestre
Centro 29 1942032024 1º Cuatrimestre
Centro 3103183183182023 1º Cuatrimestre
Centro 353103103102023 2º Cuatrimestre
Centro 343163163162023 3º Cuatrimestre
Centro 33 3163182024 1º Cuatrimestre
Centro 442882882882023 1º Cuatrimestre
Centro 473093093092023 2º Cuatrimestre
Centro 443043043042023 3º Cuatrimestre
Centro 47 3043092024 1º Cuatrimestre
Centro 5714924924922023 1º Cuatrimestre
Centro 5314944944942023 2º Cuatrimestre
Centro 5144854854852023 3º Cuatrimestre
Centro 517 4854942024 1º Cuatrimestre
1 REPLY 1
Greg_Deckler
Super User
Super User

@JosemaMz Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.