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
masplin
Impactful Individual
Impactful Individual

Bizzare inconsistent column calculation that works on most rows but not on some

I Have a model that is looking up data from one table to another using this formula

 

CaseNoteCreatedInStatus Test = var _status = 
    CALCULATE (
        VALUES ( StatusLog[Status] ),
        
        FILTER (
            StatusLog,
            StatusLog[Adviser ID]=CaseNotes[FinalisedByAdviserID] &&
            StatusLog[StatusStartDate] = CaseNotes[CreatedDate]
                && CaseNotes[CreatedTime] >= StatusLog[StatusStartTime]
                && CaseNotes[CreatedTime] < StatusLog[StatusEndTime] 
                )
        )
RETURN IF( ISBLANK(_status), "Inactive",_status)

 

This doesnt rely on any relationships.  I just had to do a major rebuild and found there wewre some odd differences.   Mostly the formula is working fine, but occassionally for a specific user on a specifc day the formula returns blankwhne it shouldn't be.  it is fine for other users on same day andthat user on other days.

 

I made a small model of an example where the formula for the 7this working but 6th isnt.  Having exported the data and reinputt he formula it works fine.

 

Here is model Test Model 

 

I have tried installing latest version power BI, rebooting, but still the same.  i can understand if it never works, but not to work 99% of the time.  Has anyone come across this and got an explanation as makes me worry this could be happening elsewhere and I would never find it?

 

Thanks for any advice

Mike

7 REPLIES 7
amitchandak
Super User
Super User

@masplin , try count in place of values. Also do you need <= in case of StatusEndTime

 

CaseNoteCreatedInStatus Test = var _status = 
    CALCULATE (
        count ( StatusLog[Status] ),
        
        FILTER (
            StatusLog,
            StatusLog[Adviser ID]=CaseNotes[FinalisedByAdviserID] &&
            StatusLog[StatusStartDate] = CaseNotes[CreatedDate]
                && CaseNotes[CreatedTime] >= StatusLog[StatusStartTime]
                && CaseNotes[CreatedTime] < StatusLog[StatusEndTime] 
                )
        )
RETURN IF( ISBLANK(_status), "Inactive",_status)
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
masplin
Impactful Individual
Impactful Individual

My point is this same formula works in this column for this user for the 7/7 not 6/7. it works for other advisers on the 6th.  So nothing wrong with the formula. Also if you look in my test pbix the calculation works fine when the data is exported. It also works fine in my new version where i have done some changes to relationships that are not involved in this calculation.  So it is being erratic not wrong.

 

COUNT produces a blank. You cant put <= end time as the status log has a next row where starttime = previouys end time so you would get multiple rows pulled back.

 

Thnaks

Mike

Hi @masplin ,

Please update the formula as below:

 
CaseNoteCreatedInStatus Test =
VAR _status =
    CALCULATE (
        MAX ( StatusLog[Status] ),
        FILTER (
            StatusLog,
            StatusLog[Adviser ID] = CaseNotes[FinalisedByAdviserID]
                && StatusLog[StatusStartDate] = CaseNotes[CreatedDate]
                && CaseNotes[CreatedTime] >= StatusLog[StatusStartTime]
                && CaseNotes[CreatedTime] < StatusLog[StatusEndTime]
        )
    )
RETURN
    IF ( ISBLANK ( _status )"Inactive"_status )

Best Regards

Rena

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

Hi StatusLog[Status] is text so wont max error?

 

Again my point is the formula is fine for most users on most days, but there are odd patches where it fails. It is also working fine on a rebuilt version of the model.  it's like the forumal engine is just failing on some specific adviserID/date combinations. 

Hi @masplin ,

You can check the below screen shot, it works well when used max function here even though StatusLog[Status] is text.

use max.JPG

You use the VALUES function in your original formula, which returns a table with one or more columns with unique values. When the return values include multiple values, an error may occur when it used in the if condition...

Best Regards

Rena

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

Hi Rena

 

I checked and the formula actually returns a blank not an error so its find no vlaues not multiple values, but again only on some rows

Hi @masplin ,

Could you please provide the data which will return blank value by the calculated column "CaseNoteCreatedInStatus Test"? What's the function of this calculated column? It is used for getting the status of per Adviser ID in specific conditions,right?

Best Regards

Rena

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

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!

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.