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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

0

DAX - Formula contain start and end dates.

Hello, everyone, I need your help.
I have a data matrix with two columns where they contain start and end dates.
I needed to know when we select a date this said it is within the time interval.

An example in the image.

I have already tried to use the dax if function .. but it doesn't work

Thank you

 

Screenshot_1.pngScreenshot_2.png

Status: Delivered

Hi @henrydhs ,

 

I wrote the ID attribute as a measure for the number of people. You can check the result below:

vtianyichmsft_0-1700012388343.png

vtianyichmsft_1-1700012482067.png

Also,you can turn off aggregation via the Totals attribute:

vtianyichmsft_2-1700012749560.png

 

 

 

Measure = CALCULATE(SUMX('Table',[Measure ID]),FILTER('Table','Table'[range]="within range"))

 

 

Best regards,
Community Support Team_ Scott Chang

Comments
v-tianyich-msft
Community Support
Status changed to: Investigating

Hi @henrydhs ,

 

Based on your description, I did simple samples to get the following results:

vtianyichmsft_0-1699858626447.png

 

 

vtianyichmsft_0-1699858413992.png

vtianyichmsft_1-1699858469750.png

 

Table 2 = CALENDAR(MIN('Table'[StartTime]),MAX('Table'[EndTime]))

range = IF(AND(SELECTEDVALUE('Table 2'[Date])>=MAX('Table'[StartTime]),SELECTEDVALUE('Table 2'[Date])<=MAX('Table'[EndTime])),"within range","")

 

 

Best regards,
Community Support Team_ Scott Chang

 

 

 

henrydhs
Frequent Visitor

Hello, Thank you for your help
but I have a problem. I want to convert the table to data format but I can't
it gives the following error

 

 

Screenshot_2.pngScreenshot_1.pngScreenshot_4.png

henrydhs
Frequent Visitor

Hello, again I managed to make the formula.
But now it only shows data if I select the day.
I wanted to choose a date range if the attribute is valid.
Example: Check if there is something within the range.

Screenshot_5.pngScreenshot_6.png

v-tianyich-msft
Community Support
Status changed to: Delivered

Hi @henrydhs ,

 

Try using the following expression:

range = IF(MAX('Table'[StartTime]) <=MAX('Table 2'[Date]) && MAX('Table'[EndTime]) >= MIN('Table 2'[Date]),"within range","")

vtianyichmsft_1-1699926607012.png

vtianyichmsft_2-1699926646667.png

 

Best regards,
Community Support Team_ Scott Chang

 

 

 

henrydhs
Frequent Visitor

Thank you. IT´s working Now.

 

Now a i have other questions 

 

- How do I remove the final part of the table "Baixa"?
- How do I count the number of people? Since it is a measure, I can't use the count formula.

I needed that when selecting a time period, it would count the number of people to calculate the number of people on "baixa".

Screenshot_1.png

v-tianyich-msft
Community Support
Status changed to: Delivered

Hi @henrydhs ,

 

I wrote the ID attribute as a measure for the number of people. You can check the result below:

vtianyichmsft_0-1700012388343.png

vtianyichmsft_1-1700012482067.png

Also,you can turn off aggregation via the Totals attribute:

vtianyichmsft_2-1700012749560.png

 

 

 

Measure = CALCULATE(SUMX('Table',[Measure ID]),FILTER('Table','Table'[range]="within range"))

 

 

Best regards,
Community Support Team_ Scott Chang

henrydhs
Frequent Visitor

Hello , I use de countax

 

Thank you

 

Solução.jpg