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
JulianS
Helper I
Helper I

Showing data of latest and previous date

Hi everyone,

 

i need to display distribution data for products based on activities which were done at a specific date.

 

The two dates should be the actual latest date for one shop id as well as the most recent date before the latest (-1)

to generate the difference between those two.

 

Previously i calculated the latest distribution with the field "is last visit" for each shop id as a filter.

I think the easiest way would be to generate another column which contains a boolean value if the date is the date before the latest one.

Can anyone help me how to build a date function that accomplishes this?

 

My data model looks like this:

dateserial numbershop iddistributionfacingsis last visit?
01.01.20171112false
01.01.20172111false
01.01.20173100false
02.12.20171111true
02.12.20172112true
02.12.20174112true
20.12.20171213true
20.12.20172215true
20.12.20173200true
20.12.20174200true

 

 

best regards,

 

Julian

1 ACCEPTED SOLUTION

Hi @v-huizhn-msft

 

thanks for the reply.

I was able to resolve the issue myself by doing the following:

1. Creating a measure which calculates the date before the max date (second to last) for each of my shops :

 

second-to-last activity date = 
CALCULATE (
    MAX( 'activities'[Date start] );
    FILTER (
        'activities;
        [Date start]  <> MAX( ( 'activities'[Date start]  )
    )
))

2. Use this measure in a column to show the date for each shop in my shop table (unique shop id).

3. Check if the dates in my distribution result table (distribution table from first post) are dates of the second-to-last date:

Data from second-to-last date? = IF(AND(distribution result[is last visit?]=FALSE();shops[second-to-last activity date]=distribution result[date]);TRUE();FALSE())

 

View solution in original post

4 REPLIES 4
v-huizhn-msft
Employee
Employee

Hi @JulianS,

How did you calculate the "is last visit" column, and what's the rules? Based on your description, it's hard to understand your requirement well, could you please list expected result and more details for further analysis?

Best Regards,
Angelia

Hi @v-huizhn-msft

 

thanks for the reply.

I was able to resolve the issue myself by doing the following:

1. Creating a measure which calculates the date before the max date (second to last) for each of my shops :

 

second-to-last activity date = 
CALCULATE (
    MAX( 'activities'[Date start] );
    FILTER (
        'activities;
        [Date start]  <> MAX( ( 'activities'[Date start]  )
    )
))

2. Use this measure in a column to show the date for each shop in my shop table (unique shop id).

3. Check if the dates in my distribution result table (distribution table from first post) are dates of the second-to-last date:

Data from second-to-last date? = IF(AND(distribution result[is last visit?]=FALSE();shops[second-to-last activity date]=distribution result[date]);TRUE();FALSE())

 

Awesome!!! Superuseful, thanks!

Hi @JulianS,

Congratulations, please mark your answer as workaround, so other people can get helpful information clearly.

Thanks,
Angelia

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.

Top Solution Authors