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
WBscooby
Helper III
Helper III

Date Slicer and Date Selector Displaying Different results

Hi

 

I have been trying to filter my data using a date slicer which is linked to a dates table. For the date range selected, I want to then find earliest sales transaction date for each Customer for my calculations.

I looked at various ideas for this and decided to create a MyDate measure to create this and then use it as a filter in my calculated measure. I am getting some unexpected results - when I use the date slicer, the calculation seems to return all information from MyDate and also anything after. When I test using a basic tick box selector, it will filter just on MyDate. Also if I put MyDate in a table it gives the correct date for each customer. I am really confused! Am I missing something in my MyDate code? Any help would be much appreciated!

MyDate =
VAR SlicerDate = MIN(DateCalendar[Date])
VAR MinDiff =
MINX(
FILTER(ALLSELECTED(SalesTransactions),
SalesTransactions[CustomerID] in values(SalesTransactions[CustomerID])
),
ABS(SlicerDate - SalesTransactions[SaleDate]))
RETURN
MINX(
FILTER(ALLSELECTED(SalesTransactions),
SalesTransactions[CustomerID] IN VALUES(SalesTransactions[CustomerID])
&& ABS(SlicerDate - SalesTransactions[SaleDate]) = MinDiff
),
SalesTransactions[SaleDate])

Mycount = CALCULATE(
COUNT(SalesTransactions[SaleID]),
SalesTransactions[NewSale]=1,
FILTER(SalesTransactions,SalesTransactions[SaleDate]= [MyDate])
)


1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@WBscooby , Not very clear. Try like, for the amount on the first date for each customer

 

Measure =
VAR __id = MAX (SalesTransactions[CustomerID] )
VAR __date = CALCULATE ( Min(SalesTransactions[SaleDate] ), ALLSELECTED (SalesTransactions ), SalesTransactions[CustomerID] = __id )
CALCULATE ( COUNT(SalesTransactions[SaleID]), VALUES (SalesTransactions[CustomerID] ),SalesTransactions[ID] = __id,SalesTransactions[SaleDate] = __date,SalesTransactions[NewSale]=1 )

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@WBscooby , Not very clear. Try like, for the amount on the first date for each customer

 

Measure =
VAR __id = MAX (SalesTransactions[CustomerID] )
VAR __date = CALCULATE ( Min(SalesTransactions[SaleDate] ), ALLSELECTED (SalesTransactions ), SalesTransactions[CustomerID] = __id )
CALCULATE ( COUNT(SalesTransactions[SaleID]), VALUES (SalesTransactions[CustomerID] ),SalesTransactions[ID] = __id,SalesTransactions[SaleDate] = __date,SalesTransactions[NewSale]=1 )

 

This worked brilliantly and a lot simpler! thank you!

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.