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
Ram_DCT
Helper II
Helper II

Flag ONLY 1st occurance of nonblank cell for each ID

Hi,

 

I need to flag 1st occurance of a nonblank number in each of my work item id and below is the sample data.

Work Item IdHoursCompleted
66928/1/2021 
66928/2/2021 
66928/3/20213
66928/4/20213
66928/5/20215
66928/6/20215
66928/7/20217
66928/8/20218
66928/9/20218
66928/10/202110
66928/11/202110
66918/5/20217
66918/6/20217
66918/7/20217
66918/8/20217
66918/9/202114
66918/10/202114
66918/11/202116
66918/12/202116
66918/13/202116

 

Expected Result with a calculated colum should be as follows:

Work Item IdHoursCompleted 
66928/1/2021 0
66928/2/2021 0
66928/3/202131
66928/4/202130
66928/5/202150
66928/6/202150
66928/7/202170
66928/8/202180
66928/9/202180
66928/10/2021100
66928/11/2021100
66918/5/202171
66918/6/202170
66918/7/202170
66918/8/202170
66918/9/2021140
66918/10/2021140
66918/11/2021160
66918/12/2021160
66918/13/2021160
2 ACCEPTED SOLUTIONS
VahidDM
Super User
Super User

Hi @Ram_DCT 

 

1- add Index column to your table in Power Query:

VahidDM_0-1630311667550.png

 

2- Use below code [DAX] to add a column to your table:

FLAG Column = 
VAR _first =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Work Item Id] ),
            'Table'[Completed] > 0
        )
    )
RETURN
    IF ( _first = 'Table'[Index], 1, 0 )

 

Output:

VahidDM_2-1630311784378.png

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

Appreciate your Kudos VahidDM_3-1630311794274.png !!

 

View solution in original post

ryan_mayu
Super User
Super User

@Ram_DCT 

based on your sample data, you can create a column directly.

Column = 
VAR _first=MINX(FILTER('Table','Table'[Work Item Id]=EARLIER('Table'[Work Item Id])&&NOT(ISBLANK('Table'[Completed]))),'Table'[Hours])
return if('Table'[Hours]=_first,1,0)

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@Ram_DCT 

based on your sample data, you can create a column directly.

Column = 
VAR _first=MINX(FILTER('Table','Table'[Work Item Id]=EARLIER('Table'[Work Item Id])&&NOT(ISBLANK('Table'[Completed]))),'Table'[Hours])
return if('Table'[Hours]=_first,1,0)

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




VahidDM
Super User
Super User

Hi @Ram_DCT 

 

1- add Index column to your table in Power Query:

VahidDM_0-1630311667550.png

 

2- Use below code [DAX] to add a column to your table:

FLAG Column = 
VAR _first =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Work Item Id] ),
            'Table'[Completed] > 0
        )
    )
RETURN
    IF ( _first = 'Table'[Index], 1, 0 )

 

Output:

VahidDM_2-1630311784378.png

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

Appreciate your Kudos VahidDM_3-1630311794274.png !!

 

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.

Top Solution Authors