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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Zahoul
Frequent Visitor

User Slicer date value in DAX expression

Hello,

 

I've been struggling with this issue, but i'm afraid there is no solution.

I have a Sales table with different lines with each a SaleDate column.

 

In my report, I use a date slicer to filter the results based on the SaleDate column.

For instance I filter from the 1st to the 30th of November. I would like to use those 2 values in a DAX expression to evaluate the performance of sales.

 

I've seen things llike using MIN and MAX of Sales[SaleDate] but unfortunately, i might not have values in november for the 1st of November or the 30th of november. I might have only values between the 10th and the 20th,but I still need to evaluate the performance for the period of the 1st > 30th.

 

I don't know if I am clear enough, but basically I need to use the 2 values of the date slicer in a DAX expression.

 

Would it be possible?


Thank you for your help,

 

Julien

 

1 ACCEPTED SOLUTION

@Zahoul

 

When you talk about your filter, is that a slicer you are using? What field  are you using for that slicer? If you use [Sales Date] you will not be able to select the dates that are not present in [Sales Date], I believe.

 

In any case, you'd need a 'Date' table with all days and create a relationship between 'Date'[date] and YourTable[Sales Date]. You then use 'Date'[date], which has all dates, in the slicer, to filter. Because of the relationship, it will filter your fact table too.

 

Google for Date/Calendar tables in DAX or similar to read about it      

View solution in original post

5 REPLIES 5
AlB
Super User
Super User

Hi @Zahoul

I'm quoting you:

I might have only values between the 10th and the 20th,but I still need to evaluate the performance for the period of the 1st > 30th

What does that mean exactly??

.

If I understand correctly you're using the Date field in Sales for the slicer.  Do you have a 'Date' table?

Zahoul
Frequent Visitor

Hello,

 

What does that mean exactly??

> It was obvious I was not clear enough 😃

Let's say I have the following Sale table:

Sale IDSale UsernameSale Date
1Bob05/03/2018
2Ryan15/03/2018
3John24/03/2018

 

 If I use my filter from the 1st to the 31th of march, and I want to use these 2 values in a DAX formula, the MIN('Sale'[Sale Date]) will give me 05/03/2018. The MAX will give me 24/03/2018.

Is there a way to get 01/03/2018 and 31/03/2018 in the DAX expression?

 

No I do not have a separate table Date. What do you mean exactly? How should I fill in this table?

 

Thank you for your help,

 

Julien

@Zahoul

 

When you talk about your filter, is that a slicer you are using? What field  are you using for that slicer? If you use [Sales Date] you will not be able to select the dates that are not present in [Sales Date], I believe.

 

In any case, you'd need a 'Date' table with all days and create a relationship between 'Date'[date] and YourTable[Sales Date]. You then use 'Date'[date], which has all dates, in the slicer, to filter. Because of the relationship, it will filter your fact table too.

 

Google for Date/Calendar tables in DAX or similar to read about it      

Zahoul
Frequent Visitor

Crystal clear, thank you!

@Zahoul

 

You can use CALENDARAUTO( ) for instance to create a Date table 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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