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
DavidNunes7
Helper I
Helper I

Measure for earlier and later dates

Hello everybody

I'm having trouble creating a measure to meet the following requirements:

I have a table where there are the inspection records of places with the date and note I need to create a table visual where my measure will return me:

  • For previous months that have no record, return the same value as the oldest recorded date;
  • For subsequent months that have no records, return the same value as the most recently recorded date                                                            
  • print.png
1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @DavidNunes7 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table and a measure. 

CALENDAR = ADDCOLUMNS(CALENDAR(DATE(2023,1,1),DATE(2023,12,31)),
"Month",FORMAT([Date],"MMMM"))
Measure 2 = var a=MAXX(FILTER(ALLSELECTED('Table'),[site name] in VALUES('Table'[site name])&&[Result]<>BLANK()),[Date])
var b=CALCULATE(SUM('Table'[Result]),FILTER('Table',EOMONTH('Table'[Date],0)=EOMONTH(MAX('CALENDAR'[Date]),0)))
var c=MINX(FILTER(ALLSELECTED('Table'),[site name] in VALUES('Table'[site name])&&[Result]<>BLANK()),[Date])
return IF(b<>BLANK(),b,IF(b=BLANK()&&MAX('CALENDAR'[Date])>a,CALCULATE(SUM('Table'[Result]),'Table'[Date]=a),IF(b=BLANK()&&MAX('CALENDAR'[Date])<C,CALCULATE(SUM('Table'[Result]),'Table'[Date]=C))))

(3) Then the result is as follows.

vtangjiemsft_0-1694166394679.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Please find attached the PBI file.

Hope this helps.

Ashish_Mathur_0-1694305379960.png

 


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

Could you give me the measurement formula?
I can't open the file because your BI version is newer,

That will be way too many steps to list.  Please retry/try on another machine with an updated version.


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

Perfect!!!!
Thank You 🙂

v-tangjie-msft
Community Support
Community Support

Hi @DavidNunes7 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a table and a measure. 

CALENDAR = ADDCOLUMNS(CALENDAR(DATE(2023,1,1),DATE(2023,12,31)),
"Month",FORMAT([Date],"MMMM"))
Measure 2 = var a=MAXX(FILTER(ALLSELECTED('Table'),[site name] in VALUES('Table'[site name])&&[Result]<>BLANK()),[Date])
var b=CALCULATE(SUM('Table'[Result]),FILTER('Table',EOMONTH('Table'[Date],0)=EOMONTH(MAX('CALENDAR'[Date]),0)))
var c=MINX(FILTER(ALLSELECTED('Table'),[site name] in VALUES('Table'[site name])&&[Result]<>BLANK()),[Date])
return IF(b<>BLANK(),b,IF(b=BLANK()&&MAX('CALENDAR'[Date])>a,CALCULATE(SUM('Table'[Result]),'Table'[Date]=a),IF(b=BLANK()&&MAX('CALENDAR'[Date])<C,CALCULATE(SUM('Table'[Result]),'Table'[Date]=C))))

(3) Then the result is as follows.

vtangjiemsft_0-1694166394679.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

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.