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

Get min date, from group with if statement

Hi, I want to create additional column, which will show minimum date from DATE column per Group where Check column is equal to "OK".

GroupDateCheckMinDate
101/01/2020  01/02/2020
101/02/2020Ok 01/02/2020
201/05/2020 01/06/2020
201/06/2020Ok01/06/2020
201/07/2020Ok01/06/2020
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@arutsjak90  if you are open to other functions than "If", following DAX can be used to create the calculated column: 

Min_date = CALCULATE(MIN([Date]),
FILTER(Table, Table[Check]="Ok"
&& Table[Group]=EARLIER(Table[Group])))
 
Capture.PNG
 
 
 
 
Did I solve your problem?
If yes, please mark my answer Accepted! 

View solution in original post

6 REPLIES 6
arutsjak90
Helper I
Helper I

Perfect, thank you @Anonymous! 

Anonymous
Not applicable

@arutsjak90  if you are open to other functions than "If", following DAX can be used to create the calculated column: 

Min_date = CALCULATE(MIN([Date]),
FILTER(Table, Table[Check]="Ok"
&& Table[Group]=EARLIER(Table[Group])))
 
Capture.PNG
 
 
 
 
Did I solve your problem?
If yes, please mark my answer Accepted! 
DataZoe
Employee
Employee

@arutsjak90 For a DAX measure it would be:

MinCheckDate =
IF (
    ISBLANK ( SELECTEDVALUE ( MinCheckDate[Group] ) ),
    BLANK (),
    CALCULATE (
        MIN ( MinCheckDate[Date] ),
        MinCheckDate[Check] = "Ok",
        REMOVEFILTERS ( MinCheckDate[Date] )
    )
)

DataZoe_0-1607527436508.png

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Thank you, but I am getting circular error. 

 

pawelkajstura11_0-1607528941081.png

 

@arutsjak90 Can you share the DAX for PSI[WhentotalIsGreater]? What I had shared actually assumes the other columns are not measures or calculated columns themselves. 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

First, there is "running total" column

Running Total Plus = CALCULATE(
SUM(PSI[ Rec./reqd.qty]),
FILTER(
PSI,
'PSI'[Plant&Material]=EARLIER(PSI[Plant&Material])
&& PSI[NewDate] <= EARLIER(PSI[NewDate])
)
)
then is 
WhenTotalIsGreater = IF(PSI[Running Total Plus]>PSI[CurrentStock],"Check","")

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.