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
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.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.