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
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
)
)
)

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
)
)
)

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