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
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
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.