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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
czuniga
Helper III
Helper III

Comparing GroupedBy Dates

I have a list of customers and the dates of their appointments like so:

 

Customer IDAptDate
1111/1/2019
1111/5/2019
2222/3/2020
4442/4/2020
5552/5/2020
5552/6/2020
5552/7/2020
8882/8/2020
9992/9/2020
9992/10/2020
9992/11/2020

 

I'm trying to figure out how to keep track of the success rate of scheduling customers next appointment when they visit.  Successful Dataset would look like this (1 = NextAptScheduled): 

 

Customer IDAptDate (Past & Future)NextAptScheduled
1111/1/20191
1115/1/20210
2222/3/20200
4442/4/20200
5552/5/20201
5552/6/20201
5552/7/20200
8882/8/20200
9992/9/20201
9992/10/20201
9992/11/20220

 

I'm thinking it makes sense to group the customers by their ID's with the dates of their purchases, but am having a hard time figuring if I should do that with a groupby, summarize,  or summarizecolumns, and how to work with the dates in their respective groups to achieve the goal from there. 

 

Any help would be greatly appreciated. Thank you! 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=1*(not(CALCULATE(MAX(Data[AptDate (Past & Future)]),FILTER(Data,Data[Customer ID]=EARLIER(Data[Customer ID])))=Data[AptDate (Past & Future)]))

Hope this helps.

Untitled.png


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

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=1*(not(CALCULATE(MAX(Data[AptDate (Past & Future)]),FILTER(Data,Data[Customer ID]=EARLIER(Data[Customer ID])))=Data[AptDate (Past & Future)]))

Hope this helps.

Untitled.png


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

You can use this expression for a new Column on your Appointments table (replace with your actual table name).  I added a comment too in case you need the measure version in a table visual with your customer ID and Date columns.

 

NextApptScheduled =
VAR vThisDate = Appointments[AptDate]  //use MIN(Appointments[AptDate]) if a measure is needed instead
RETURN
    IF (
        ISBLANK (
            CALCULATE (
                COUNTROWS ( Appointments ),
                ALLEXCEPT (
                    Appointments,
                    Appointments[Customer ID]
                ),
                Appointments[AptDate] > vThisDate
            )
        ),
        0,
        1
    )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


PhilipTreacy
Super User
Super User

Hi @czuniga 

Please supply some sample data and your expected result so we can see what we're working with.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thanks for the suggestion. Done! 

amitchandak
Super User
Super User

@czuniga , expected output is not clear . But these columns can help

 

rank Column for dates = rankx(filter(Table, [Customer] = earlier([customer]) ), [Date],,asc)


last purcahse date date = maxx(filter(Table, [Customer] = earlier([customer]) && [Date] = earlier([Date])),[Date])

Tried again to explain what I'm trying to accomplish as I wasn't able to get what you suggested work. Appreciate the input though! 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.