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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
swisdom
Helper I
Helper I

Calculation IF a value appears in earlier rows

I have a set of data including RMAs with various dates. I would like to create a measure which calculates if a particular Serial Number has been returned multiple times, and IF it does, to calculate the date difference between the most recent Actual Ship Date and the current Date Submitted.

 

 Link to sample .pbix file 

 

For example:

Serial numDate submittedDate actual shipIF multiple, Days between
x234321/3/20211/25/2021NA
x854233/4/20214/2/2021NA
x234326/4/20216/17/2021141(6/4/2021-1/25/2021)
x964235/3/20215/26/2021NA
x854237/2/20217/19/202192 (7/2/2021-4/2/2021)
x234329/6/202110/2/202182 ( 9/6/2021-6/17/2021)
5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

This should typically be a calculated column formula.  You may download my PBI file from here.

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello thank you for your response!

So your method looks great, however when I try to apply it to my actual dataset (not the test dataset) I get this error: "Circular dependency was detected"

swisdom_0-1644453193426.png

(I split up the code a bit just for myself so I could read it easier)

 

Any ideas why I would get that error?

Mine is a calculated column formula solution (not a measure solution).


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Thank you for providing the sample data

 

 

If multiple, Days between = 
var ds=SELECTEDVALUE(RMA[Date Submitted])
var pasd = CALCULATE(max(RMA[ACTUAL_SHIP_DATE]),ALLEXCEPT(RMA,RMA[Serial Num]),RMA[ACTUAL_SHIP_DATE]<ds)
return DATEDIFF(pasd,ds,DAY)

 

 

lbendlin_0-1644193100232.png

 

Thank you for your response!

So I can see that this is working on your pbix file, but for some reason when I apply it to my own file, it does something weird and gives values for entries that shouldn't have them (see below)

swisdom_0-1644451284300.png

The ones highlighted in green are correct, but the rest I believe should be blank?

 

Any idea what is going wonky?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.