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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
sandeep_sharma
Helper II
Helper II

Consider previous month value if current month value is blank

Hi Friends,

 

I have few blank values for some of the months for some of the names. I want to show previous month value if current month value is blank. so for example in the below snapshot of HOURS SPENT. In March, value for Ankit Gupta is blank, I want to show 9 for March against Ankit Gupta as this is his previous month value.

 

sandeep_sharma_0-1674535691687.png

 

Below is my backend data:

 

sandeep_sharma_1-1674535719148.png

 

Please help

 

Great thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sandeep_sharma ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1674630317734.png

2. create a measure with below dax formula

Measure =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR max_date =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Date] < cur_date && 'Table'[Name] = cur_name ),
        [Date]
    )
VAR _val =
    CALCULATE (
        MAX ( 'Table'[Hours Spent] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = cur_date && 'Table'[Name] = cur_name )
    )
VAR _val2 =
    CALCULATE (
        MAX ( 'Table'[Hours Spent] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = max_date && 'Table'[Name] = cur_name )
    )
RETURN
    IF ( ISBLANK ( _val ), _val2, _val )

3. add a matrix visual with fields and measure

vbinbinyumsft_1-1674630402578.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, 

Thanks for the solution !

I am kind of facing with similar problem. In my case if the if a person does not have any hours recorded against him in any particular month his name is skipped from that month. To encounter the issue I have created two databases. First database contains all the months and second data contains all the names. These two databases are connected to the master sheet. Lets consider the master sheet same as what sandeep_Sharma has provided.

How can i write a DAX to overcome the issue ?

Anonymous
Not applicable

Hi @sandeep_sharma ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1674630317734.png

2. create a measure with below dax formula

Measure =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR max_date =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Date] < cur_date && 'Table'[Name] = cur_name ),
        [Date]
    )
VAR _val =
    CALCULATE (
        MAX ( 'Table'[Hours Spent] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = cur_date && 'Table'[Name] = cur_name )
    )
VAR _val2 =
    CALCULATE (
        MAX ( 'Table'[Hours Spent] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = max_date && 'Table'[Name] = cur_name )
    )
RETURN
    IF ( ISBLANK ( _val ), _val2, _val )

3. add a matrix visual with fields and measure

vbinbinyumsft_1-1674630402578.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Would it be possible to also add the value of April for name B and C. For this case it would have the take the value of last available value which for this case would be Feb value. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.