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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Brij
Helper II
Helper II

Dax to filter table based on touch start date and touch end date and two dates on slicer

Hi,
I am trying to write a DAX to check a condition to find out whether it is a STRAT WIP or END WIP

START WIP: IF "touch start date" is less than or equal to start date of date slicer AND ("touch end date" is equal to BLANK() OR "touch end date" is greater than or equal to start date of date slicer) then output should be "Y" else "N"

 

END WIP: IF "touch start date" is less than or equal to end date of date slicer AND ("touch end date" is equal to BLANK () OR "touch end date" is greater than or equal to end date of date slicer) then output should be "Y" else "N"

 

Once I find this out, I will then need to get the count of application ID to place it on a card visual to show the number of START WIP and another card to show the number of END WIP.

 

touch start date and touch end date is from the 'touch' table

Start date and End date from slicer is from the 'date' table

 

below is the scenario 

All dates are in dd/mm/yyyy format

Date sclicer range is 1/03/2022 to 5/03/2022

 

 Start DateEnd Date  
Date slicer1/03/20225/03/2022  
    
Application IDTouch Start DateTouch End DateStart WIPEnd WIP
A00125/02/202225/02/2022NN
A00125/02/20222/03/2022YN
A00225/02/2022 YY
A00228/02/20221/03/2022YN
A0031/03/20221/03/2022YN
A0041/03/20223/03/2022YN
A0052/03/20224/03/2022NN
A0052/03/20225/03/2022NY
A0063/03/20223/03/2022NN
A0064/03/20224/03/2022NN
A0074/03/2022 NY
A0085/03/2022 NY
     
OUTPUT   
Start WIP for the period5   
End WIP for the period4   

 

 

3 ACCEPTED SOLUTIONS
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Brij 

 

You have a Date table for the Date slicer, right?

Vera_33_0-1648688457911.png

 

Start WIP for the period = 
VAR CurStart= MIN('Date'[Date])
VAR T1=ADDCOLUMNS(Table2,"StartWIP", IF([Touch Start Date]<=CurStart&& OR([Touch End Date]>=CurStart,ISBLANK([Touch End Date])),1,0))
RETURN
SUMX(T1,[StartWIP])


End WIP for the period = 
VAR CurEnd=MAX('Date'[Date])
VAR T1=ADDCOLUMNS(Table2,"EndWIP", IF([Touch Start Date]<=CurEnd&& OR([Touch End Date]>=CurEnd,ISBLANK([Touch End Date])),1,0))
RETURN
SUMX(T1,[EndWIP])

View solution in original post

Brij
Helper II
Helper II

Hi @Vera_33 

Thanks for the solution. It seems fine and I've worked out my queries above.

 

The result of these measures returns a total number of START WIP and END WIP which is what I needed. However, what if I want to see the underlying data behind these returned number? I understand it is sitting in a virtual table so is there a way to bring in front for user to verify?

 

Thanks again,

Brij

 

View solution in original post

Hi @Vera_33 , I've worked this out to see the underlying data of these measure. I've created a new report page and then on the table I've added require columns from the original table. Use these measures as drillthrough. Filter the table with require result from these measure. It works. Thanks for your help!

View solution in original post

12 REPLIES 12
Ashish_Mathur
Super User
Super User

Hi,

I am trying to solve the problem with measures only.  I could not get the answer as 5 and 4.  My results are turning out to be 4 and 3 which i know are incorrect but this could be a starting point for further refinement.

Hope this helps.  You may download my PBI file from here.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur  I'm not able to connect to Onedrive where your file is located due to access restriction on my organisatoin. Are you able to upload it here instead? Thanks.

Please find attached.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur 

 

If you disconnect your Calendar with Data table, then it works

Vera_33_0-1648783200085.png

 

Hi,

Thank you for replying.  I wonder why that happens.  Why is the Calendar Table proving to be a bottleneck?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Brij
Helper II
Helper II

Hi @Vera_33 

Thanks for the solution. It seems fine and I've worked out my queries above.

 

The result of these measures returns a total number of START WIP and END WIP which is what I needed. However, what if I want to see the underlying data behind these returned number? I understand it is sitting in a virtual table so is there a way to bring in front for user to verify?

 

Thanks again,

Brij

 

Hi @Vera_33 , I've worked this out to see the underlying data of these measure. I've created a new report page and then on the table I've added require columns from the original table. Use these measures as drillthrough. Filter the table with require result from these measure. It works. Thanks for your help!

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Brij 

 

You want to show it in a visual, like this?

Vera_33_0-1648773288253.png

Start WIP = 
VAR CurStart=MIN('Date'[Date])
VAR CurStartDate=MAX([Touch Start Date])
VAR CurEndDate=MAX([Touch End Date])
RETURN
IF(CurStartDate<=CurStart&& OR(CurEndDate>=CurStart,ISBLANK(CurEndDate)),1,0)

 

Hi @Vera_33 

Thanks for the solution and your prompt reply.

Yes, this is what I like to see in a tabular form, just to verify the total number. However, when I applied the same in my model it is not giving me the same result!😕 See below screenshot;

Brij_0-1648777625485.png

 

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Brij 

 

Can you check the file shared by @Ashish_Mathur , see if it is the same shape as your dataset?

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Brij 

 

You have a Date table for the Date slicer, right?

Vera_33_0-1648688457911.png

 

Start WIP for the period = 
VAR CurStart= MIN('Date'[Date])
VAR T1=ADDCOLUMNS(Table2,"StartWIP", IF([Touch Start Date]<=CurStart&& OR([Touch End Date]>=CurStart,ISBLANK([Touch End Date])),1,0))
RETURN
SUMX(T1,[StartWIP])


End WIP for the period = 
VAR CurEnd=MAX('Date'[Date])
VAR T1=ADDCOLUMNS(Table2,"EndWIP", IF([Touch Start Date]<=CurEnd&& OR([Touch End Date]>=CurEnd,ISBLANK([Touch End Date])),1,0))
RETURN
SUMX(T1,[EndWIP])

Hi, Thanks,

 

Yes, I do have a date table.

 

Just checking is this a measure or a calculated column? Also Table 2 in your DAX is my 'touch' table, right?

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.