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
ggzmorsh
Helper II
Helper II

Distinct Count of a value from the last updated date

I am working in a logistics company where we deliver the shipments to the the client. I have a simple report that has duplicate datas which i need to put in the dashboard and what i need is the value that was last updated from a date column/row on a slicer.

1.PNG

 

Table:

DateReference NoCountryRemarks
07/23/2019AWB1111CHINAPending
07/24/2019AWB1111CHINADelivered
07/24/2019AWB1112AMERICAPending
07/24/2019AWB1113AFRICAPending
07/24/2019AWB1114JAPANPending
07/24/2019AWB1115SPAINPending
07/24/2019AWB1116CANADAPending
07/24/2019AWB1117AMERICAPending
07/24/2019AWB1118CANADAPending
07/24/2019AWB1119CANADAPending
07/24/2019AWB1120AMERICAPending
07/24/2019AWB1121CHINAPending
07/25/2019AWB1112AMERICADelivered
07/25/2019AWB1113AFRICADelivered
07/25/2019AWB1122SPAINPending
07/25/2019AWB1123AMERICAPending
07/25/2019AWB1124JAPANPending
07/25/2019AWB1125JAPANPending
07/25/2019AWB1126CHINAPending
07/25/2019AWB1127CHINAPending
07/25/2019AWB1128AMERICAPending

Where my report matrix/table would only give me the distinct count of the value(Reference No) from the latest or newest date on the slicer(Update Date). If i add my Remarks column it should not give me duplicates on both remarks as the result would only give me distinct count of the Reference No with its Remark on the maximum or newest date.

 

Count Matrix:

count.PNG

Where AMERICA has 1 Delivered and 5 Pending gave me a total of 6, AWB1112 has values on both 7/24 and 7/25 

it should not give me the count for the previous day if it also appears on a later date. AWB1111 1112 1113 shows up 2 times in different dates. 

 

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @ggzmorsh ,

I created a sample you can reference.

  • create a calendar table as a slicer
Table = CALENDARAUTO()
  • create a calculated column to get the maximum date 

 

Column = MAX(Table1[Date])
  • create a measure
Measure = 
var a = CALCULATE(DISTINCTCOUNT(Table1[Reference No]),FILTER(Table1,'Table1'[Date]= Table1[Column] && Table1[Date] >= MIN('Table'[Date])&&Table1[Date] <= MAX('Table'[Date])))
var b = CALCULATE(DISTINCTCOUNT(Table1[Reference No]),FILTER(Table1,Table1[Date] = MAX('Table'[Date])))
return
IF(ISBLANK(b),a,b)

2.PNG

Here is my sample you can download.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
ggzmorsh
Helper II
Helper II

I will get back to you when i test the data before the week ends. Thanks

v-xuding-msft
Community Support
Community Support

Hi @ggzmorsh ,

Could you tell me if your problem has been solved? If it is, kindly mark the helpful answer as a solution if you feel that makes sense. Welcome to share your own solution. More people will benefit from here.

 

Best Regards,

Xue

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I did not know this would be useful, thanks.

Table = CALENDARAUTO()

 

 

I used the formula as per your sampleand it is only showing me the last date from the calendarauto if i referenced it to Table and if i referenced it from my table.

Column = MAX(Table1[Date])

From your Table1From your Table1

My TableMy Table

 

And it would not allow me to download your sample.

 

 

 

 

 

v-xuding-msft
Community Support
Community Support

Hi @ggzmorsh ,

I created a sample you can reference.

  • create a calendar table as a slicer
Table = CALENDARAUTO()
  • create a calculated column to get the maximum date 

 

Column = MAX(Table1[Date])
  • create a measure
Measure = 
var a = CALCULATE(DISTINCTCOUNT(Table1[Reference No]),FILTER(Table1,'Table1'[Date]= Table1[Column] && Table1[Date] >= MIN('Table'[Date])&&Table1[Date] <= MAX('Table'[Date])))
var b = CALCULATE(DISTINCTCOUNT(Table1[Reference No]),FILTER(Table1,Table1[Date] = MAX('Table'[Date])))
return
IF(ISBLANK(b),a,b)

2.PNG

Here is my sample you can download.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.