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
jalaomar
Helper IV
Helper IV

If then else statement

Hi all,

 

in need for some help and hopefully someone can support 🙂

 

currently i have two columns, ActualDate & ScheduleStart Date 

 

in my Matrix table i would like create a measure to display for example 

Contract --> if ActualDate is availble display this date but else display ScheduleStartDate or blank if no data availble in the two columns 

 

Does someone know how this measure could be stated?

 

THANKS!

2021-04-29_09-41-33.png2021-04-29_09-43-00.png

3 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@jalaomar , Create a column like this and use

 

coalesce([ActualDate],[ScheduleStartDate])

 

or a measure

 

maxx(table, coalesce(table[ActualDate],table[ScheduleStartDate]))

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

View solution in original post

Hi @jalaomar ,

 

Try the following formula:

Measure = 
SWITCH(
    MAX('Table'[BaselinePurpose]),
    "Contract", MAXX('Table', coalesce('Table'[ActualStart],'Table'[ScheduleStart])),
    "Current", MAX('Table'[ActualStart]),
    "ActualSchedule", MAX('Table'[ActualStart])
)

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Hi @jalaomar ,

 

Try the following formula:

Measure_Date = 
IF(
    MAX('Table'[Actual Start]) <> BLANK(),
    MAX('Table'[Actual Start]),
    MAX('Table'[Schedule Start])
)
Actual/Schedule vs Contr = 
DATEDIFF(
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "Contract"),
        _Measure[Measure_Date]
    ),
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "ActualSchedule"),
        '_Measure'[Measure_Date]
    ),
    DAY
)
Actual/Schedule vs Curr = 
DATEDIFF(
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "Current"),
        _Measure[Measure_Date]
    ),
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "ActualSchedule"),
        _Measure[Measure_Date]
    ),
    DAY
)

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

 

Best Regards,
Winniz

View solution in original post

9 REPLIES 9
jalaomar
Helper IV
Helper IV

Many thanks @v-kkf-msft !

The measure works great 🙂

amitchandak
Super User
Super User

@jalaomar , Create a column like this and use

 

coalesce([ActualDate],[ScheduleStartDate])

 

or a measure

 

maxx(table, coalesce(table[ActualDate],table[ScheduleStartDate]))

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, Many thanks!

 

is it possible to put a condition to the measure?

 

in my rows i have 

Contract Baseline 

Current Baseline 

Actual/schedule 

 

for contract baseline i would like to use the measure you created 

for Current baseline i would like to only show actual dates according to the tollgate the project is currently in (example ITG2 and blank in the following tollgates)

for Actual/schedule date i only want to visualize the Actual date accodring to which tollgate the projects is in currently (example ITG2)

 

Possible to put these conditions in plase?

 

Thanks!

 

Best regards,

Jala

Hi @jalaomar ,

 

Try the following formula:

Measure = 
SWITCH(
    MAX('Table'[BaselinePurpose]),
    "Contract", MAXX('Table', coalesce('Table'[ActualStart],'Table'[ScheduleStart])),
    "Current", MAX('Table'[ActualStart]),
    "ActualSchedule", MAX('Table'[ActualStart])
)

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

 

 

Hi @v-kkf-msft 

to follow up on this topic i am wondering if you could maybe support me to create measures that calculate the delta for the different baselinePurpose as shown in below picture?

deviation between Actual/Schedule vs Contract baseline

deviation between Actual/Schedule vs contract baseline 

2021-05-10_11-07-20.png

Many thanks!

 

BR

Jala

Hi @jalaomar ,

 

I don't know your model, so I create some sample data. Then create measures:

 

Actual/Schedule vs Contr = 
DATEDIFF(
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "Contract"),
        'Table'[Date]
    ),
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "ActualSchedule"),
        'Table'[Date]
    ),
    DAY
)
Actual/Schedule vs Curr = 
DATEDIFF(
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "Current"),
        'Table'[Date]
    ),
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "ActualSchedule"),
        'Table'[Date]
    ),
    DAY
)

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

 

Best Regards,
Winniz

Hi @v-kkf-msft Thanks for looking into this 

 

the measure is not displaying as i would like to but the calculation is correct.

 

for BaselinePurpose 

Contract 

Current 

Actual/schedule

I need to take into considiration that if there is a "ActualStart" date then the measure should be based on that date else take the "ScheduleStart" Date 

 

se below picture of a little sample of the dataset

I will visialize the measure in a matrix table where the

BaselinePurpose is the rows and Tollgate is the columns and the measure is the value 

Hope this made it a bit more clear, otherwise let me know

 

Many thanks!!

2021-05-11_10-24-45.png

2021-05-11_10-34-47.png

Hi @jalaomar ,

 

Try the following formula:

Measure_Date = 
IF(
    MAX('Table'[Actual Start]) <> BLANK(),
    MAX('Table'[Actual Start]),
    MAX('Table'[Schedule Start])
)
Actual/Schedule vs Contr = 
DATEDIFF(
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "Contract"),
        _Measure[Measure_Date]
    ),
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "ActualSchedule"),
        '_Measure'[Measure_Date]
    ),
    DAY
)
Actual/Schedule vs Curr = 
DATEDIFF(
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "Current"),
        _Measure[Measure_Date]
    ),
    MAXX(
        FILTER('Table','Table'[BaselinePurpose] = "ActualSchedule"),
        _Measure[Measure_Date]
    ),
    DAY
)

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

 

Best Regards,
Winniz

Hi @v-kkf-msft 

much better, thanks!!

It work as intended 🙂 

2021-05-11_13-43-02.png

 

 

Best regards,

Jala

 

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!

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