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
Anonymous
Not applicable

calculate dax if previous value is blank

Dear all...

need some help with dax.

 

the column is a accumative total and i need to calculate the no. of sales per month.

the blank value indicate the days when sales is closed.

 

how do i calculate the difference if the previous value is blank.

there could be 2 or more blank cell.

 

Capture.JPG

Thank you so much.

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi Washivale , 

You also could refer to my sample to see whether it work or not.

Best Regards,
Zoe Zhi

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

4 REPLIES 4
Washivale
Resolver V
Resolver V

Hi @Anonymous ,

 

You might need to add more details on what exactly you are trying to do with this data, tried downloading file from the link with no luck.

 

per your screenshot, if you just need number of sales per month, a simple calculate function as below should be sufficient.

 

= Calculate(Count(SalesIdCol), commulativevaluecol <>blank())

 

Thanks,

Washivale

Anonymous
Not applicable

@Washivale 

hihi..

i need the no. of sales per month but because there are blank value, so i need the formula to take the previous value...

there are times when there are more than 2 blank value.

Hi @Anonymous ,

 

still getting an error message on gofile, i tried to reproduce a table from your screenshot, and created a measure as below

 

EndResults = VAR lrv = SELECTEDVALUE(Query1[Value])
Return
if(lrv=blank(),0, lrv-CALCULATE(
    LASTNONBLANK('Query1'[Value],1),
    FILTER(
        ALLSELECTED('Query1'[Date]),
        ISONORAFTER('Query1'[Date], MAX('Query1'[Date])-1, DESC)
    )
))
 
check if it helps.
 
 
image.png
Regards,
Washivale
dax
Community Support
Community Support

Hi Washivale , 

You also could refer to my sample to see whether it work or not.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.