Inquiry about the operation of DrawImage - c++
Query GdipDrawImageRectRect operation
I am currently working on adding an image to the print
PS. I am using Visual studio 2019, and all 32,64bit DLLs are using WindowSDK 10.0 (latest installed version) and toolset is using v142.
Below is my code.
Graphics* ImageLogoGraphices = new Graphics(hDC);
ImageAttributes ImgAttr;
ImageLogoGraphices->ResetTransform();
ImageLogoGraphices->SetPageUnit(UnitPixel);
ColorMatrix ClrMatrix = {
1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, rLogoImgDensity, 0.0f,
0.0f, 0.0f, 0.0f ,0.0f, 1.0f
};
ImgAttr.SetColorMatrix(&ClrMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
Image ImageLogo(MyPNGFilePath);
REAL rImageWidth = ImageLogo.GetWidth();
REAL rImageHeight = ImageLogo.GetHeight();
RectF mRect(0, 0, RectnWidth, RectnHeight);
SizeF RectSize;
mRect. GetSize(&RectSize);
status = ImageLogoGraphices->DrawImage(&ImageLogo, mRect, 0, 0, rImageWidth, rImageHeight, UnitPixel, &ImgAttr);
After writing and testing the program as above, the result is as follows.
PostScript Driver PCL Driver
32bit O O
64bit X O
Therefore, I checked the reason why 64 bit of PostScript does not work properly.
In this regard, I checked additionally using API Monitor.
In other normal behavior, calling DrawImage will call GdipDrawImageRectRect and then call StretchDIBits to draw the image.
But 64bit's PostScript Driver calls DrawImage, calls GdipDrawImageRectRect, exits, and doesn't call StretchDIBits. I think this is the cause.
Below is the log from API Monitor.
[32bit PostScript Driver - Normal Action]
5 3:31:57.692 PM 2 myModule.dll GdipDrawImageRectRect ( 0x046b1cf0, 0x0c866ef0, 0.000000, 0.000000, 1024.000000, 1024.000000, 0.000000, 0.000000, 256.000000, 256.000000, UnitPixel, 0x046befb0, NULL, NULL ) Ok 0.0361396
6 3:31:57.692 PM 2 gdiplus.dll GetDC ( NULL ) 0x12011c42 0.0000368
7 3:31:57.692 PM 2 gdiplus.dll GetDeviceCaps ( 0x12011c42, LOGPIXELSX ) 96 0.0000059
8 3:31:57.692 PM 2 gdiplus.dll GetDeviceCaps ( 0x12011c42, LOGPIXELSY ) 96 0.0000012
9 3:31:57.692 PM 2 gdiplus.dll ReleaseDC ( NULL, 0x12011c42 ) 1 0.0000141
10 3:31:57.694 PM 2 gdiplus.dll SaveDC ( 0xc421123d ) 1 0.0000294
11 3:31:57.694 PM 2 gdiplus.dll SetICMMode ( 0xc421123d, ICM_OFF ) 1 0.0000022
12 3:31:57.694 PM 2 gdi32full.dll GetDeviceCaps ( 0xc421123d, NUMCOLORS ) 8 0.0000005
13 3:31:57.694 PM 2 gdiplus.dll SetMapMode ( 0xc421123d, MM_TEXT ) 1 0.0000009
14 3:31:57.694 PM 2 gdiplus.dll SetViewportOrgEx ( 0xc421123d, 0, 0, NULL ) TRUE 0.0000009
15 3:31:57.694 PM 2 gdiplus.dll SetWindowOrgEx ( 0xc421123d, 0, 0, NULL ) TRUE 0.0002221
16 3:31:57.694 PM 2 gdiplus.dll SetROP2 ( 0xc421123d, R2_COPYPEN ) 11 0.0000017
17 3:31:57.694 PM 2 gdiplus.dll ModifyWorldTransform ( 0xc421123d, NULL, MWT_IDENTITY ) FALSE 0 0.0001478
18 3:31:57.694 PM 2 gdiplus.dll SelectClipRgn ( 0xc421123d, NULL ) 2 0.0000315
19 3:31:57.694 PM 2 gdi32full.dll ExtSelectClipRgn ( 0x3c212371, NULL, RGN_COPY ) 2 0.0000104
20 3:31:57.694 PM 2 gdi32full.dll ExtSelectClipRgn ( 0xc421123d, NULL, RGN_COPY ) 2 0.0000194
21 3:31:57.695 PM 2 gdiplus.dll BeginPath ( 0xc421123d ) TRUE 0.0000160
22 3:31:57.695 PM 2 gdiplus.dll MoveToEx ( 0xc421123d, 4229, 6288, NULL ) TRUE 0.0000010
23 3:31:57.695 PM 2 gdiplus.dll PolylineTo ( 0xc421123d, 0x0615acdc, 4 ) TRUE 0.0000117
24 3:31:57.695 PM 2 gdiplus.dll CloseFigure ( 0xc421123d ) TRUE 0.0000051
25 3:31:57.695 PM 2 gdiplus.dll EndPath ( 0xc421123d ) TRUE 0.0000023
26 3:31:57.695 PM 2 gdiplus.dll StrokePath ( 0xc421123d ) TRUE 0.0005179
27 3:31:57.698 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6288, 1024, 4, 0, 0, 256, 1, 0x0c87c9a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001633
28 3:31:57.698 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6292, 1024, 4, 0, 0, 256, 1, 0x0c87c5a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001344
29 3:31:57.698 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6296, 1024, 4, 0, 0, 256, 1, 0x0c87c1a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001528
30 3:31:57.698 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6300, 1024, 4, 0, 0, 256, 1, 0x0c87bda8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001249
31 3:31:57.698 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6304, 1024, 4, 0, 0, 256, 1, 0x0c87b9a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001090
32 3:31:57.698 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6308, 1024, 4, 0, 0, 256, 1, 0x0c87b5a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001758
33 3:31:57.699 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6312, 1024, 4, 0, 0, 256, 1, 0x0c87b1a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001288
34 3:31:57.699 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6316, 1024, 4, 0, 0, 256, 1, 0x0c87ada8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001237
35 3:31:57.699 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6320, 1024, 4, 0, 0, 256, 1, 0x0c87a9a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001090
36 3:31:57.699 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6324, 1024, 4, 0, 0, 256, 1, 0x0c87a5a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0001197
37 3:31:57.699 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6328, 1024, 4, 0, 0, 256, 1, 0x0c87a1a8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1 0.0000855
38 3:31:57.699 PM 2 gdiplus.dll StretchDIBits ( 0xc421123d, 4232, 6332, 1024, 4, 0, 0, 256, 1, 0x0c879da8, 0x0615afe4, DIB_RGB_COLORS, SRCCOPY ) 1
[64bit PostScript Driver - Bad Action]
5 3:33:20.986 PM 11 myModulex64.dll GdipDrawImageRectRect ( 0x0000000010b52630, 0x0000000003e60f90, 0.000000, 0.000000, 1024.000000, 1024.000000, 0.000000, 0.000000, 256.000000, 256.000000, UnitPixel, 0x0000000010b522a0, NULL, NULL ) Ok 0.0053892
6 3:33:20.986 PM 11 gdiplus.dll GetDC ( NULL ) 0x0000000000011fab 0.0000818
7 3:33:20.986 PM 11 gdiplus.dll GetDeviceCaps ( 0x0000000000011fab, LOGPIXELSX ) 96 0.0000062
8 3:33:20.986 PM 11 gdiplus.dll GetDeviceCaps ( 0x0000000000011fab, LOGPIXELSY ) 96 0.0000011
9 3:33:20.986 PM 11 gdiplus.dll ReleaseDC ( NULL, 0x0000000000011fab ) 1 0.0000428
10 3:33:20.987 PM 11 gdiplus.dll SaveDC ( 0x0000000000212243 ) 1 0.0000256
11 3:33:20.987 PM 11 gdiplus.dll SetICMMode ( 0x0000000000212243, ICM_OFF ) 1 0.0000027
12 3:33:20.987 PM 11 gdi32full.dll GetDeviceCaps ( 0x0000000000212243, NUMCOLORS ) 8 0.0000005
13 3:33:20.987 PM 11 gdiplus.dll SetMapMode ( 0x0000000000212243, MM_TEXT ) 1 0.0000015
14 3:33:20.987 PM 11 gdiplus.dll SetViewportOrgEx ( 0x0000000000212243, 0, 0, NULL ) TRUE 0.0000007
15 3:33:20.987 PM 11 gdiplus.dll SetWindowOrgEx ( 0x0000000000212243, 0, 0, NULL ) TRUE 0.0001646
16 3:33:20.987 PM 11 gdiplus.dll SetROP2 ( 0x0000000000212243, R2_COPYPEN ) 11 0.0000024
17 3:33:20.987 PM 11 gdiplus.dll ModifyWorldTransform ( 0x0000000000212243, NULL, MWT_IDENTITY ) FALSE 0 0.0002172
18 3:33:20.988 PM 11 gdiplus.dll SelectClipRgn ( 0x0000000000212243, NULL ) 2 0.0000214
19 3:33:20.988 PM 11 gdi32full.dll ExtSelectClipRgn ( 0xffffffffb72124b1, NULL, RGN_COPY ) 2 0.0000059
20 3:33:20.988 PM 11 gdi32full.dll ExtSelectClipRgn ( 0x0000000000212243, NULL, RGN_COPY ) 2 0.0000137
21 3:33:20.989 PM 11 gdiplus.dll BeginPath ( 0x0000000000212243 ) TRUE 0.0000183
22 3:33:20.989 PM 11 gdiplus.dll MoveToEx ( 0x0000000000212243, 4229, 6288, NULL ) TRUE 0.0000017
23 3:33:20.989 PM 11 gdiplus.dll PolylineTo ( 0x0000000000212243, 0x0000000003bda430, 4 ) TRUE 0.0000213
24 3:33:20.989 PM 11 gdiplus.dll CloseFigure ( 0x0000000000212243 ) TRUE 0.0000048
25 3:33:20.989 PM 11 gdiplus.dll EndPath ( 0x0000000000212243 ) TRUE 0.0000021
26 3:33:20.989 PM 11 gdiplus.dll StrokePath ( 0x0000000000212243 ) TRUE 0.0004295
Why is the behavior different?
Related
DAX: Cumulative Completion Rate with Month Slicer
I'm trying to calculate cumulative completion rate by all users over moths, the issue is that in the below table for ex when I filter on october it divides users who finished till october / all users except those who finished in November. I have a dim_date table which is connect to the data table, the retaltion is between Date from dim_date and Completion Date from Data table Also in dim date table im numbering the months 1,2,3,4 etc ID Completion_status Completion Date 1 0 2 0 3 0 4 0 5 0 6 1 11/1/2022 7 1 11/1/2022 8 1 11/1/2022 9 1 11/2/2022 10 1 11/1/2022 11 1 11/6/2022 12 1 11/4/2022 13 1 11/2/2022 14 1 10/13/2022 15 1 10/14/2022 16 1 10/14/2022 17 1 10/13/2022 18 1 10/15/2022 19 1 10/13/2022 20 1 10/13/2022 21 1 10/13/2022 22 1 10/13/2022 23 1 10/18/2022 24 1 10/13/2022 25 1 10/13/2022 26 1 10/13/2022 27 1 10/13/2022 28 1 9/10/2022 29 1 9/8/2022 the formula I use Completion% = VAR comp rate = SUM(Table[completion_status]) / count(Table[ID]) Return CALCULATE(Table[Completion%],filter(ALL(Dim_Date),Dim_Date[Month Number] <= MAX(Dim_Date[Month Number]))) the expected result when I filter on september is 2/29 = 7% on october is 16/29 = 55% on November is 24/29 = 83%
Something like: = VAR SelectedMonth = MIN( Dim_Date[Month Number] ) VAR CumulativeTotal = CALCULATE( COUNTROWS( 'Table' ), FILTER( ALL( Dim_Date ), Dim_Date[Month Number] <= SelectedMonth && NOT ( ISBLANK( Dim_Date[Month Number] ) ) ) ) VAR CountAllRows = CALCULATE( COUNTROWS( 'Table' ), ALL( Dim_Date ) ) RETURN DIVIDE( CumulativeTotal, CountAllRows ) I'm presuming that Dim_Date[Month Number] is blank when Table[Completion Date] is blank. You may want to replace ALL with, for example, ALLSELECTED, depending on your required set-up.
Django ORM fill 0 for missing date
I'm using Django 2.2. I want to generate the analytics of the number of records by each day between the stand and end date. The query used is start_date = '2021-9-1' end_date = '2021-9-30' query = Tracking.objects.filter( scan_time__date__gte=start_date, scan_time__date__lte=end_date ) query.annotate( scanned_date=TruncDate('scan_time') ).order_by( 'scanned_date' ).values('scanned_date').annotate( **{'total': Count('created')} ) Which produces output as [{'scanned_date': datetime.date(2021, 9, 24), 'total': 5}, {'scanned_date': datetime.date(2021, 9, 26), 'total': 3}] I want to fill the missing dates with 0, so that the output should be 2021-9-1: 0 2021-9-2: 0 ... 2021-9-24: 5 2021-9-25: 0 2021-9-26: 3 ... 2021-9-30: 0 How I can achieve this using either ORM or python (ie., pandas, etc.)?
Use DataFrame.reindex by date range created by date_range with DatetimeIndex by DataFrame.set_index: data = [{'scanned_date': datetime.date(2021, 9, 24), 'total': 5}, {'scanned_date': datetime.date(2021, 9, 26), 'total': 3}] start_date = '2021-9-1' end_date = '2021-9-30' r = pd.date_range(start_date, end_date, name='scanned_date') #if necessary convert to dates from datetimes #r = pd.date_range(start_date, end_date, name='scanned_date').date df = pd.DataFrame(data).set_index('scanned_date').reindex(r, fill_value=0).reset_index() print (df) scanned_date total 0 2021-09-01 0 1 2021-09-02 0 2 2021-09-03 0 3 2021-09-04 0 4 2021-09-05 0 5 2021-09-06 0 6 2021-09-07 0 7 2021-09-08 0 8 2021-09-09 0 9 2021-09-10 0 10 2021-09-11 0 11 2021-09-12 0 12 2021-09-13 0 13 2021-09-14 0 14 2021-09-15 0 15 2021-09-16 0 16 2021-09-17 0 17 2021-09-18 0 18 2021-09-19 0 19 2021-09-20 0 20 2021-09-21 0 21 2021-09-22 0 22 2021-09-23 0 23 2021-09-24 5 24 2021-09-25 0 25 2021-09-26 3 26 2021-09-27 0 27 2021-09-28 0 28 2021-09-29 0 29 2021-09-30 0 Or use left join by another DataFrame create from range with replace misisng values to 0: r = pd.date_range(start_date, end_date, name='scanned_date').date df = pd.DataFrame({'scanned_date':r}).merge(pd.DataFrame(data), how='left', on='scanned_date').fillna(0)
PowerBI - Select last non-blank value of a Measure based on most recent Date
I have the following table in PowerBI : FullDate Visits Orders ConversionRate 01/02/2020 00:00:00 100 20 0,20 01/02/2020 01:00:00 550 78 0,14 01/02/2020 02:00:00 652 60 0,09 01/02/2020 03:00:00 0 0 0,00 01/02/2020 04:00:00 0 0 0,00 01/02/2020 05:00:00 0 0 0,00 ConversionRate is a measure : ConversionRate = DIVIDE(SUM(Table[Orders]),SUM(Table[Visits])) I need to get the value of trying to display in a card the latest non-blank value of ConversionRate based on the date. I tried this but it returned empty in all the fields : LastValue = CALCULATE( DIVIDE(SUM([Orders]),SUM([Visits])), FILTER(Table, Table[FullDate] = MAX( Table[FullDate] ) && Table[Visits] <> 0 ) ) This returned the same value as ConversionRate for each row. FullDate Visits Orders ConversionRate LastValue 01/02/2020 00:00:00 100 20 0,20 0,20 01/02/2020 01:00:00 550 78 0,14 0,14 01/02/2020 02:00:00 652 60 0,09 0,09 01/02/2020 03:00:00 0 0 0,00 0,00 01/02/2020 04:00:00 0 0 0,00 0,00 01/02/2020 05:00:00 0 0 0,00 0,00 What I want is : FullDate Visits Orders ConversionRate LastValue 01/02/2020 00:00:00 100 20 0,20 0,09 01/02/2020 01:00:00 550 78 0,14 0,09 01/02/2020 02:00:00 652 60 0,09 0,09 01/02/2020 03:00:00 0 0 0,00 0,00 01/02/2020 04:00:00 0 0 0,00 0,00 01/02/2020 05:00:00 0 0 0,00 0,00 I am sure I am missing something but I am new to DAX.. Any help would be appreciated
You want to capture your 'max' date before you begin the iteration over 'Table' in the Filter function. Doing the calculation to discover the max date and assigning it to a variable gets this done. Then you use your variable in the filter function, and you get the proper result. An unwanted side effect is that the .09 is calculated in every row, so you have check that Visit column a second time and return a blank if its value is zero. LastConversion = VAR maxDate = CALCULATE ( MAX ( 'Table'[FullDate] ), FILTER ( ALL ( 'Table' ), 'Table'[Visits] <> 0 ) ) RETURN IF ( SUM ( 'Table'[Visits] ) = 0, BLANK (), CALCULATE ( DIVIDE ( SUM ( [Orders] ), SUM ( [Visits] ) ), FILTER ( ALL('Table'), 'Table'[FullDate] = maxDate ) ) )
Problem with if condition in my fortran code
I have been trying to extract the atom number corresponding to atom name "OW" using if condition in fortran code from a file. But when I am using the 'if condition' the values are not written in a file. Could anybody help me regarding the same where I am doing wrong. implicit none character(len=100)::head,grofile character(len=5):: res_nm,at_name integer :: n,i,ierror,at_num write(*,*) 'enter the name of gro file' read(*,*) grofile open(unit=10,file=grofile,status='old',action='read') openif : if (ierror == 0) then !open was ok. Read values. read(10,*)head read(10,*)n do i=1,n read(10,200) at_name,at_num if (at_name == 'OW') then write(44,*)at_num 200 format (10x,a5,i5) endif enddo endif openif end program name and the input file that I am using is CNT in water 44316 1LIG C 1 2.814 2.448 2.231 -0.2002 0.0645 -0.2005 1LIG C 2 2.783 2.584 2.233 0.4146 0.2083 -0.1403 1LIG C 3 2.769 2.658 2.350 -0.4678 -0.0886 -0.0500 1LIG C 4 2.687 2.772 2.348 -0.7671 -0.3032 -0.0624 1LIG C 5 2.619 2.795 2.228 -0.2327 -0.2483 -0.3593 1LIG C 6 2.486 2.837 2.238 -0.0621 0.2349 -0.0781 ................ 1LIG H 1006 2.613 1.972 12.082 -1.2767 0.0570 0.2045 1LIG H 1007 2.804 2.173 12.099 -0.4228 1.8734 1.9762 1LIG H 1008 2.862 2.377 12.097 -0.7176 -2.2587 1.0804 2water OW 1009 2.221 1.281 6.853 -0.6831 -0.3395 0.1402 2water HW1 1010 2.191 1.215 6.789 -1.2195 0.6304 -0.6225 2water HW2 1011 2.143 1.333 6.871 -0.5687 -0.7024 1.7263 2water MW 1012 2.206 1.279 6.847 -0.7389 -0.2594 0.2489 3water OW 1013 2.826 4.482 12.736 -0.2852 0.1750 0.1277 3water HW1 1014 2.735 4.490 12.707 -0.3265 -0.3844 0.1046 3water HW2 1015 2.860 4.406 12.689 0.4937 0.9762 -0.6120 3water MW 1016 2.818 4.473 12.726 -0.1879 0.2065 0.0267 4water OW 1017 3.510 2.042 10.165 0.1154 -0.0258 -0.0813 4water HW1 1018 3.530 2.105 10.095 3.0124 -0.2562 0.4945 4water HW2 1019 3.434 1.993 10.132 -0.4188 1.8748 -1.7521 ............... 4.90369 4.90369 14.25892 Also, I am not getting any error for the code and without any output. The command that I am using gfortran br_br_gofr_smooth_dlp4.f90 -o read -I /usr/local/include/ -lgmxfort -g -fcheck=all -fbounds-check ./read
You have two errors: You are using ierror uninitialised, as noted in the comments at_name is a length 5 character variable. You are comparing it with a 2 letter character variable. For this to be true the leftmost 2 characters of at_name have to be the same as those in the two character variable. Unfortunately as your code is written it reads the atom name into the rightmost 2 characters of at_name. Thus the test fails The code below shows a way of fixing the above, and does what I think you want. Especially for point 2 there are other ways. ijb#ijb-Latitude-5410:~/work/stack$ cat pdb.f90 implicit none character(len=100)::head,grofile character(len=5):: res_nm,at_name integer :: n,i,ierror,at_num write(*,*) 'enter the name of gro file' read(*,*) grofile open(unit=10,file=grofile,status='old',action='read',iostat=ierror) openif : if (ierror == 0) then !open was ok. Read values. read(10,*)head read(10,*)n do i=1,n read(10,200) at_name,at_num if (Adjustl(at_name) == 'OW') then write(44,*)at_num 200 format (10x,a5,i5) endif enddo endif openif end program ijb#ijb-Latitude-5410:~/work/stack$ gfortran -std=f2008 -Wall -Wextra -fcheck=all -g -O pdb.f90 pdb.f90:3:27: 3 | character(len=5):: res_nm,at_name | 1 Warning: Unused variable ‘res_nm’ declared at (1) [-Wunused-variable] ijb#ijb-Latitude-5410:~/work/stack$ cat stuff CNT in water 20 1LIG C 1 2.814 2.448 2.231 -0.2002 0.0645 -0.2005 1LIG C 2 2.783 2.584 2.233 0.4146 0.2083 -0.1403 1LIG C 3 2.769 2.658 2.350 -0.4678 -0.0886 -0.0500 1LIG C 4 2.687 2.772 2.348 -0.7671 -0.3032 -0.0624 1LIG C 5 2.619 2.795 2.228 -0.2327 -0.2483 -0.3593 1LIG C 6 2.486 2.837 2.238 -0.0621 0.2349 -0.0781 1LIG H 1006 2.613 1.972 12.082 -1.2767 0.0570 0.2045 1LIG H 1007 2.804 2.173 12.099 -0.4228 1.8734 1.9762 1LIG H 1008 2.862 2.377 12.097 -0.7176 -2.2587 1.0804 2water OW 1009 2.221 1.281 6.853 -0.6831 -0.3395 0.1402 2water HW1 1010 2.191 1.215 6.789 -1.2195 0.6304 -0.6225 2water HW2 1011 2.143 1.333 6.871 -0.5687 -0.7024 1.7263 2water MW 1012 2.206 1.279 6.847 -0.7389 -0.2594 0.2489 3water OW 1013 2.826 4.482 12.736 -0.2852 0.1750 0.1277 3water HW1 1014 2.735 4.490 12.707 -0.3265 -0.3844 0.1046 3water HW2 1015 2.860 4.406 12.689 0.4937 0.9762 -0.6120 3water MW 1016 2.818 4.473 12.726 -0.1879 0.2065 0.0267 4water OW 1017 3.510 2.042 10.165 0.1154 -0.0258 -0.0813 4water HW1 1018 3.530 2.105 10.095 3.0124 -0.2562 0.4945 4water HW2 1019 3.434 1.993 10.132 -0.4188 1.8748 -1.7521 4.90369 4.90369 14.25892 ijb#ijb-Latitude-5410:~/work/stack$ ls -lrt | tail -rw-rw-r-- 1 ijb ijb 1106 Jun 11 05:43 pi_orig.f90 -rw-rw-r-- 1 ijb ijb 958 Jun 11 05:56 pi_ijb.f90~ -rw-rw-r-- 1 ijb ijb 1805 Jun 11 06:07 pi_ijb.f90 -rw-rw-r-- 1 ijb ijb 1106 Jun 11 06:29 pi2.f90~ -rw-rw-r-- 1 ijb ijb 1305 Jun 11 06:34 pi2.f90 -rw-rw-r-- 1 ijb ijb 537 Jun 14 08:39 pdb.f90~ -rw-rw-r-- 1 ijb ijb 1462 Jun 14 08:40 stuff~ -rw-rw-r-- 1 ijb ijb 1425 Jun 14 08:41 stuff -rw-rw-r-- 1 ijb ijb 560 Jun 14 08:43 pdb.f90 -rwxrwxr-x 1 ijb ijb 20520 Jun 14 08:49 a.out ijb#ijb-Latitude-5410:~/work/stack$ ./a.out enter the name of gro file stuff ijb#ijb-Latitude-5410:~/work/stack$ ls -lrt | tail -rw-rw-r-- 1 ijb ijb 958 Jun 11 05:56 pi_ijb.f90~ -rw-rw-r-- 1 ijb ijb 1805 Jun 11 06:07 pi_ijb.f90 -rw-rw-r-- 1 ijb ijb 1106 Jun 11 06:29 pi2.f90~ -rw-rw-r-- 1 ijb ijb 1305 Jun 11 06:34 pi2.f90 -rw-rw-r-- 1 ijb ijb 537 Jun 14 08:39 pdb.f90~ -rw-rw-r-- 1 ijb ijb 1462 Jun 14 08:40 stuff~ -rw-rw-r-- 1 ijb ijb 1425 Jun 14 08:41 stuff -rw-rw-r-- 1 ijb ijb 560 Jun 14 08:43 pdb.f90 -rwxrwxr-x 1 ijb ijb 20520 Jun 14 08:49 a.out -rw-rw-r-- 1 ijb ijb 39 Jun 14 08:49 fort.44 ijb#ijb-Latitude-5410:~/work/stack$ cat fort.44 1009 1013 1017 ijb#ijb-Latitude-5410:~/work/stack$
Return latest value present in power BI
I am trying to create a calculated column in power BI called most recent score that gives me the most recent score for each employee. Employee Number Date Score Most recent score 1234 01/01/2019 1 1 1235 01/01/2019 4 2 1236 01/01/2019 2 3 1288 01/01/2019 0 0 1259 01/01/2019 0 1 1234 01/02/2019 3 1 1235 01/02/2019 4 2 1236 01/02/2019 1 3 1288 01/02/2019 2 0 1259 01/02/2019 4 1 1234 01/03/2019 1 1 1235 01/03/2019 2 2 1236 01/03/2019 3 3 1288 01/03/2019 0 0 1259 01/03/2019 1 1 1234 01/04/2019 BLANK 1 1235 01/04/2019 BLANK 2 1236 01/04/2019 BLANK 3 1288 01/04/2019 BLANK 0 1259 01/04/2019 BLANK 1 I am using the below measure which seems to work unless the most recent score is a "0" in which case it pulls through the most recent non "0" score. Most Recent Score = VAR MRSM = Master[Employee ID] RETURN CALCULATE ( LASTNONBLANK ( Master[Score], Master[Score] ), FILTER ( Master, Master[Employee ID] = MRSM ) ) Any help would be appreciated
EDITED ANSWER This seems to do what you need. Most Recent Score = VAR EmpID = 'Master'[Employee ID] VAR tblScores = FILTER ('Master', 'Master'[Employee ID] = EmpID && NOT ( ISBLANK ( 'Master'[Score] ) ) ) VAR mrsDate = CALCULATE ( MAX ( [Date] ), tblScores ) RETURN CALCULATE ( MAX ( 'Master'[Score] ), FILTER ( tblScores, 'Master'[Date] = mrsDate ) )