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.

Reply
samoht103
Frequent Visitor

Help for a novice / newbie please

Hi, I am trying to find the first date, last date, number of orders and refunds for each company. I'm sure this is pretty simple, but any help is much appreciated. I have included a sample of ten records and the output I am seeking below. Thanks heaps 😊

 

Record_noCompanyDateType
1ABC1/05/2020Sale
2XYZ2/05/2020Sale
3ABC1233/05/2020Refund
4ABC4/05/2020Refund
5XYZ5/05/2020Refund
6ABC1236/05/2020Sale
7ABC7/05/2020Sale
8XYZ8/05/2020Refund
9ABC1239/05/2020Sale
10Abc10/05/2020Refund
11ABC1239/05/2020Refund

 

Company NameTotal Number of SalesEarliest Sale DateMost Recent Sale DateTotal Number of SalesFirst Refund DateMost Recent Refund DateDays Between 1st Sale Last Refund
ABC21/05/20207/05/202024/05/202010/05/20209
XYZ12/05/20202/05/202015/05/20208/05/20206
ABC12326/05/20209/05/202023/05/20209/05/20203

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@samoht103 , Create measures like these

Total Number of Sales = calculate(count(table[Record_no]),	table[Type]="Sales")
Total Number of Refund = calculate(count(table[Record_no]),	table[Type]="Refund")

Earliest  Sales date = calculate(Min(table[Date]),	table[Type]="Sales")
Most Recent Sales date = calculate(max(table[Date]),	table[Type]="Sales")

Earliest  Refund date = calculate(Min(table[Date]),	table[Type]="Refund")
Most Recent Refund date = calculate(max(table[Date]),	table[Type]="Refund")

Days Between 1st Sale Last Refund = datediff([Earliest  Refund date],[Most Recent Refund date],Day)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@samoht103 , Create measures like these

Total Number of Sales = calculate(count(table[Record_no]),	table[Type]="Sales")
Total Number of Refund = calculate(count(table[Record_no]),	table[Type]="Refund")

Earliest  Sales date = calculate(Min(table[Date]),	table[Type]="Sales")
Most Recent Sales date = calculate(max(table[Date]),	table[Type]="Sales")

Earliest  Refund date = calculate(Min(table[Date]),	table[Type]="Refund")
Most Recent Refund date = calculate(max(table[Date]),	table[Type]="Refund")

Days Between 1st Sale Last Refund = datediff([Earliest  Refund date],[Most Recent Refund date],Day)
nahid3152
Helper II
Helper II

HI,
You can use max & Min function for getting first date & last Date

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.