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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
CallumJ
Frequent Visitor

If Else Date Question

Hi All,

Ratting around in my brain to see how this would work, here is my data:

No.StageDate
1P10/05/2022
1F12/08/2022
1A 
2P 
2F15/06/2022
2A22/08/2022
3P 
3F20/08/2022
3A 
4P25/06/2022
4F25/04/2022
4A15/06/2022

 

P, F & A are Planned, Forecast & Actual. I am creating a new table (Duplicated query and grouped columns) for this data which amalgamates it, part of the requirement is that I must populate the date column in a certain way - If there is an Actual Date, use that, else use Forecast Date, Else use Planned Date.

New Table:

No.Date
112/08/2022
222/08/2022
320/08/2022
415/06/2022

 

I'm a bit lost as to how to reference the Stage column while using those If & Else conditions. Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
Tahreem24
Super User
Super User

@CallumJ Create a Column like this:

Column =
VAR A_ = CALCULATE(MAX(StageTable[Date]),StageTable[Stage]="A",ALLEXCEPT(StageTable,StageTable[No.]))
VAR P_ = CALCULATE(MAX(StageTable[Date]),StageTable[Stage]="P",ALLEXCEPT(StageTable,StageTable[No.]))
VAR F_ = CALCULATE(MAX(StageTable[Date]),StageTable[Stage]="F",ALLEXCEPT(StageTable,StageTable[No.]))
RETURN SWITCH(TRUE(),
A_=BLANK(),F_,
P_=BLANK(),A_,
F_=BLANK(),A_,
A_
)
 
Capture.JPG
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

4 REPLIES 4
Tahreem24
Super User
Super User

@CallumJ Create a Column like this:

Column =
VAR A_ = CALCULATE(MAX(StageTable[Date]),StageTable[Stage]="A",ALLEXCEPT(StageTable,StageTable[No.]))
VAR P_ = CALCULATE(MAX(StageTable[Date]),StageTable[Stage]="P",ALLEXCEPT(StageTable,StageTable[No.]))
VAR F_ = CALCULATE(MAX(StageTable[Date]),StageTable[Stage]="F",ALLEXCEPT(StageTable,StageTable[No.]))
RETURN SWITCH(TRUE(),
A_=BLANK(),F_,
P_=BLANK(),A_,
F_=BLANK(),A_,
A_
)
 
Capture.JPG
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

You are a star, thank you!

amitchandak
Super User
Super User

@CallumJ , Based on what I got

A new calculated table in dax  =

Summarize(Filter(Table, not(isblank(Table[Date])) , Table[No], "Date", Max(Table[Date]) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amitchandak,

Appreciate your response, however I need an order of preference for the Dates, i.e. if A ISNOTNULL() then use the A Date, else if F ISNOTNULL() then use F Date, else if P ISNOTNULL() then use 'Null'.

The distinction is that it doesn't matter what date is the Max/Min, I need to set up an order of prefence. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors