cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alexcatala
Helper IV
Helper IV

Calculate Footfall values from opening date

Hi,

 

I have recently found a mistake in my formula, as it doesn't filter the Footfall values since our store was opened. For example, we opened a store in late august and power bi made a calculation from the whole month, not from the opening date.

alexcatala_0-1631704269536.png

As you can see we opened the store last year on the 29th, and I would like only to count from the day it was opened, otherwise, you can see the variance between years are huge.

 

Currently the formula I am using for Footfall (D):

Footfall (D) =
VAR BoP_Date_Fixed = [BoP Date]
VAR d_StoresAuto_Enriched =
ADDCOLUMNS (
d_StoresAuto,
"Include", MAX (
[COMP_Active] * ( [OpeningDateAniversary] <= BoP_Date_Fixed ),
[NEW_Active] * ( [OpeningDateAniversary] > BoP_Date_Fixed )
)
)
VAR d_StoresAuto_Enriched_Filtered =
FILTER ( d_StoresAuto_Enriched, [Include] = 1 )
VAR Result =
SUMX (
d_StoresAuto_Enriched_Filtered,
CALCULATE ( SUM ( 'f_DailyFootfall'[Traffic]) )
)
RETURN
IF ( Result = 0, [ND_Sign], Result )

 

For the opening date, we have the values located in a different table:

 

d_StoreAuto(OpeningDate)

 

Any suggestion?

 

Thanks in advance for your support.

1 ACCEPTED SOLUTION

Hi @alexcatala ,

 

Please try the following formula:

 

Footfall (D) =
VAR BoP_Date_Fixed = [BoP Date]
VAR d_StoresAuto_Enriched =
ADDCOLUMNS (
d_StoresAuto,
"Include", MAX (
[COMP_Active] * ( [OpeningDateAniversary] <= BoP_Date_Fixed ),
[NEW_Active] * ( [OpeningDateAniversary] > BoP_Date_Fixed )
)
)
VAR d_StoresAuto_Enriched_Filtered =
FILTER ( d_StoresAuto_Enriched, [Include] = 1 )
VAR Result =
SUMX (
d_StoresAuto_Enriched_Filtered,
CALCULATE ( SUM ( 'f_DailyFootfall'[Traffic]), FILTER('d_StoresAuto','d_StoresAuto'[Date] >= 'd_StoresAuto'[OpeningDate]) )
)
RETURN
IF ( Result = 0, [ND_Sign], Result )

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

6 REPLIES 6
v-kkf-msft
Community Support
Community Support

Hi @alexcatala ,

 

Has your problem been solved? If it is solved, please mark a reply which is helpful to you.

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

 

Best Regards,
Winniz

amitchandak
Super User
Super User

@alexcatala , if you are looking for life to date, then the opening date has no role. As there will be no data before.

What is data and what is the issue

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s || 50+Power Query List Functions : Learn Power Query List
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

@amitchandak 

 

Hi,

 

The issue is I would like to start calculating the values from the opening date of the store, not before.

 

Is that possible?

 

As when we open a new store we don't only want to start calculating since the store was opened.

 

alexcatala_0-1631711389842.png

 

Here you can see the Footfall is counting(employees and maintenance) when the store wasn't opened yet.

I would like only the count/sum of the values since the opening date, not before.

@alexcatala , See if one of the two ways can help 

 

Footfall new= if(isblank[Sales D]), Blank(), [Footfall])

or

footfall new = calculate([Footfall], filter(Date, Date[Date]>= calculate(Min(Table[Date]),allexcept(Table, Table[Store]))))

 

Table is table of sales



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s || 50+Power Query List Functions : Learn Power Query List
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

@amitchandak 

 

I have tried your suggestion but it didn't work

 

alexcatala_0-1631787560494.png

 

It keeps showing the value before the opening date.

 

footfall new = calculate([Footfall (D)], filter(d_StoresAuto,d_StoresAuto[OpeningDate]>= calculate(Min(d_StoresAuto[OpeningDate]),allexcept(d_StoresAuto,d_StoresAuto[Store]))))
 
Any other idea that might work?
 
I want just to take the values since the opening date.
 
Thanks in advance

Hi @alexcatala ,

 

Please try the following formula:

 

Footfall (D) =
VAR BoP_Date_Fixed = [BoP Date]
VAR d_StoresAuto_Enriched =
ADDCOLUMNS (
d_StoresAuto,
"Include", MAX (
[COMP_Active] * ( [OpeningDateAniversary] <= BoP_Date_Fixed ),
[NEW_Active] * ( [OpeningDateAniversary] > BoP_Date_Fixed )
)
)
VAR d_StoresAuto_Enriched_Filtered =
FILTER ( d_StoresAuto_Enriched, [Include] = 1 )
VAR Result =
SUMX (
d_StoresAuto_Enriched_Filtered,
CALCULATE ( SUM ( 'f_DailyFootfall'[Traffic]), FILTER('d_StoresAuto','d_StoresAuto'[Date] >= 'd_StoresAuto'[OpeningDate]) )
)
RETURN
IF ( Result = 0, [ND_Sign], Result )

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Dev Camp Session 26

Check it Out!

Mark your calendars and join us on Thursday, September 29 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors