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
domdre35
New Member

Days open in month (for stores)

Hello everyone,

 

to begin with, thank you for beeing part of this cumminty 🙂

 

Since several days I am working now on this issue.

 

I have a list with stores and open dates (see beloew) and a DimDate Table

 

Store_ID         Open Date

Store 1           15.01.2018  

Store 2           20.02.2018

Store 3           10.03.2018

 

I want to calculate for each month the total amount of days a store was opened (instead od dynamic 30/31 days a fixed value of 30 for full month is ok).

 

Example

 

January                    February               March                        or    Year (Jan-March)

15+0+0=15            30+10+0=40       30+30+20=80                  15+40+80=135

 

Is this possible, if yes, could you please help me with dax measure? Thank you very much in advance!

 

DoM

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @domdre35,


Please take a look at following measure formula if it suitable for your requirement:

Remain days =
VAR _start =
    FIRSTDATE ( VALUES ( 'Calendar'[Date] ) )
VAR _end =
    LASTDATE ( VALUES ( 'Calendar'[Date] ) )
RETURN
    SUMX (
        FILTER (
            ALL ( Store ),
            [Open Date] IN CALENDAR ( _start, _end )
                || [Open Date] <= _start
        ),
        DATEDIFF ( MAX ( [Open Date], _start ), _end, DAY )
    )

22.gif

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @domdre35,


Please take a look at following measure formula if it suitable for your requirement:

Remain days =
VAR _start =
    FIRSTDATE ( VALUES ( 'Calendar'[Date] ) )
VAR _end =
    LASTDATE ( VALUES ( 'Calendar'[Date] ) )
RETURN
    SUMX (
        FILTER (
            ALL ( Store ),
            [Open Date] IN CALENDAR ( _start, _end )
                || [Open Date] <= _start
        ),
        DATEDIFF ( MAX ( [Open Date], _start ), _end, DAY )
    )

22.gif

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.