cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DaHolla
Frequent Visitor

Count of Closed Stores by Sales with Exceptions

I need to get a count of closed stores where closed is defined as a store with less than $100 in sales for any given day. The tricky part is that certain stores always close on Sunday and these stores need to be excluded from the count, but only on Sundays. If they close on a Tuesday, they need to be included in the count.

Here's what I have so far. It seems to give me the correct counts by day, but the total is incorrect. Any help would be appreciated.

TempClosure =
CALCULATE (
    COUNTROWS (
        FILTER (
            SUMMARIZE (
                Sales,
                Sales[Date],
                Sales[Store],
                "ClosedFlag", IF ( SUM ( Sales[SalesNet] ) < 100, 1, 0 ),
                "SpecialStoreFlag", IF ( Sales[RestaurantKey] IN { 001, 002 }, 1, 0 ),
                "SpecialDayFlag", IF ( SELECTEDVALUE ( 'DATE'[DayNameInt] ) = 1, 1, 0 )
            ),
            [ClosedFlag] = 1
                && ( [SpecialStoreFlag] = 0
                && [SpecialDayFlag] = 0 )
                || ( [SpecialStoreFlag] = 1
                && [SpecialDayFlag] = 0 )
                || ( [SpecialStoreFlag] = 0
                && [SpecialDayFlag] = 1 )
        )
    )
)


In the above code I feel that the first three rows of the filter expression should suffice, but then I lose all sundays or all days for the special stores.

DaHolla_0-1625775963507.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DaHolla , Try a measure like

 

TempClosure =
CALCULATE (
Sumx (
SUMMARIZE (
Sales,
Sales[Date],
sales([Day of Week]) , // Create a new column weekday([Date],2)
Sales[Store],
"Sales", SUM ( Sales[SalesNet] )
),
Switch(true() , ([Sales] <100 && [Day of Week] <> 7) , 1, 0
)
)
)

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@DaHolla , Try a measure like

 

TempClosure =
CALCULATE (
Sumx (
SUMMARIZE (
Sales,
Sales[Date],
sales([Day of Week]) , // Create a new column weekday([Date],2)
Sales[Store],
"Sales", SUM ( Sales[SalesNet] )
),
Switch(true() , ([Sales] <100 && [Day of Week] <> 7) , 1, 0
)
)
)

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors