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
Anonymous
Not applicable

Count status of item on latest occurrence

Hi All,

Brief : There are multiple visits to a particular store in week/month for different kind of item checks by a person.

Visit DateItemStoreItem Present/AbsentWeek
1-Jan-21AABCAbsent1
2-Jan-21BCDFPresent1
3-Jan-21BXYZPresent1
4-Jan-21AFMSPresent1
29-Jan-21AABCPresent4
31-Jan-21BCDFAbsent4
1-Feb-21BPLOAbsent5
1-Feb-21BCDFPresent5
2-Feb-21AABCPresent5
3-Feb-21AGHYPresent5


Above is the scenario. Consider week as calendar weeks (data here might be different , for logic puspose I have considered 1 Jan 2021 as week 1).


CASE 1 :
User Selects Jan in time slicer.
Expected Output is

ItemPresent in StoresAbsent in StoresTotal Unique Stores for Item
A1 1
B112

 

This needs to happen dynamically as in , when multiple months are selected only the latest instance of unique visit(Item+Date+Store) should be considered for absent or present calculation.
Latest visit may not necessarily fall on last date of selected period.


CASE 2 : 
User selects Jan and Feb in slicer
Expected Output

ItemPresent in StoresAbsent in StoresTotal Unique Stores for Item
A3 1
B213


Kindly help.

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

 

How to get the desired result? Could you please consider sharing more details about it?

It makes it easier to give you a solution.

  1. Sample (dummy dataset) data as text, use the table tool in the editing bar
  2. Expected output from sample data
  3. Explanation in words of how to get from 1. to 2.

vangzhengmsft_0-1646966580989.png

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

AllisonKennedy
Super User
Super User

@Anonymous The LASTDATE() function should help you here. Note it will use the filters you have selected so will show the last date that the product/store has a row in the table. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

LastDate() did not seem to fulfil the requirement. But Calculating a virtual table with MAXDATE function seems to work. Thanks for your time . Appriciate it.

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.