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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
George_H
Frequent Visitor

DAX Events In Progress with other conditions.

Hi all,

I have quite a complicated issue, with doing a events in progress with muiltpe outcomes. I've managed to do the code in Excel but I'm unsure how to translate this into DAX. I would basically like to go back in time with a calender slicer, in put a range to see how many pets adoptions were in progress, completed and withdrawn. 

 

The sheet is regularly updated telling me the status of all pet adoptions. I have start day of progressing the adoption and Status date of when the adoption finalises. On the Status date if the adoption is still in progress, it will be equal to the start date. If the adoption gets completed or withdrawn then the status date will be day this happened. 

This is the logic breakdown I came up with in Excel. 

 

Step 1Check if Status is "on break" or if has start date or if the Status Date & Start day match. If either is TRUE, then Current Status
  
Step 2If Start date is less than sliced date, return "Not Started"
  
Step 3If sliced date is greater than the start date, less than the end date and end date is not equal to 0, then return "In Progress"
  
Step 4If Status = "In Progress" then return "In Progress"
  
Step 5Finally if Status = Withdrawn than return "Withdrawn" Otherwise "Completed"

 

I've managed to make this work in Excel with the current code. 

=IF(OR(B2="Break/Paused",C2=D2,C2=0),B2,IF($G$3<C2,"Not Started",IF(AND($G$3>C2,$H$3<D2,D2<>0),"In Progress",IF(B2="In Progress","In Progress",IF(B2="Withdrawn","Withdrawn","Completed")))))

 

Where B is Apprentice Status

C Start is Start Date

D is Status Date.

G&H would be date used for the slicer, It is just fixed in Excel for conventiece. So for example if the slicer is set to 01/04/2021 – 01/04/2022, it will tell me all the live adoptions during that period. 

 

I've tried doing this in DAX with the following code, but not going to lie I don't really know what I'm doing!

Datesbetween =
VAR EndDate = MAX('Fiscal Table'[Date])
VAR StartDate = MIN('Fiscal Table'[Date])
VAR Result =
CALCULATE(
    [Adoptions],
    REMOVEFILTERS('Fiscal Table'),
    'Adoptions Data'[Start Date of Adoption] <= EndDate,
    'Adoptions Data'[Status Date] > StartDate
)
Return
Result

 

 

I hope I have made sense, and thanks for reading!

 

 

 

3 REPLIES 3
George_H
Frequent Visitor

Hi all, I'm still struggling with this issue and updated with more detail. I hope it makes more sense now!

amitchandak
Super User
Super User

@George_H , to me $J$1 seem like static value , that you can have in var

 

Var _val = <Value of $j1>

return

=IF(OR(B2="Break/Paused",[C]=0),B2,IF(_val <[C],"Not Started",IF(AND(_val >[C],_val<[D],[D]<>0),"In Progress",IF([B]="In Progress","In Progress",IF([D[="Withdrawn","Withdrawn","Completed")))))

 

You can also use switch true

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi,

Thanks for getting back to me. I didn't explain it, but J$1 would be the dates in the slicer it would be checking through. 

How I want it to work is to be able to slice down date ranges, so for example  “how many pet adoptions were live between 01/04/2021 – 01/04/2022”I want my dashboard to be able to count the number of pet adoptions that are in progress during sliced times. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.