cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
greeshma
Post Partisan
Post Partisan

period table creation

hi 

i was looking for dax  to create a period table 

from where i can pick a period like rolling 6 months, last quarter etc...

i have listed time period l am looking to create

greeshma_0-1612894939278.png

greeshma_1-1612895018148.png

 

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

Hi @greeshma ,

 

Indeed, it will be a little troublesome to use dax.

 

1.Create a calendar table and a category table.

46.png

Table = CALENDAR(DATE(2020,1,1),DATE(2021,12,31))

43.png

 

2.Create a relationship between calendar table and main table.

45.png

 

3.Create the measure

FilteredValue =
SWITCH (
    SELECTEDVALUE ( 'Table (2)'[Category] ),
    "Today", CALCULATE ( SUM ( MainTable[Value] ), FILTER ( 'Table', [Date] = TODAY () ) ),
    "Yesterday",
        CALCULATE (
            SUM ( MainTable[Value] ),
            FILTER ( 'Table', [Date] = TODAY () - 1 )
        ),
    "Month to Date",
        CALCULATE (
            SUM ( MainTable[Value] ),
            DATESINPERIOD ( 'Table'[Date], TODAY (), -1, MONTH )
        ),
    "Rolling 7 days",
        CALCULATE (
            SUM ( MainTable[Value] ),
            FILTER ( 'Table', [Date] <= TODAY () && [Date] >= TODAY () - 6 )
        )
)

 

You can check more details from here.

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @greeshma ,

 

Indeed, it will be a little troublesome to use dax.

 

1.Create a calendar table and a category table.

46.png

Table = CALENDAR(DATE(2020,1,1),DATE(2021,12,31))

43.png

 

2.Create a relationship between calendar table and main table.

45.png

 

3.Create the measure

FilteredValue =
SWITCH (
    SELECTEDVALUE ( 'Table (2)'[Category] ),
    "Today", CALCULATE ( SUM ( MainTable[Value] ), FILTER ( 'Table', [Date] = TODAY () ) ),
    "Yesterday",
        CALCULATE (
            SUM ( MainTable[Value] ),
            FILTER ( 'Table', [Date] = TODAY () - 1 )
        ),
    "Month to Date",
        CALCULATE (
            SUM ( MainTable[Value] ),
            DATESINPERIOD ( 'Table'[Date], TODAY (), -1, MONTH )
        ),
    "Rolling 7 days",
        CALCULATE (
            SUM ( MainTable[Value] ),
            FILTER ( 'Table', [Date] <= TODAY () && [Date] >= TODAY () - 6 )
        )
)

 

You can check more details from here.

 

Best Regards,

Stephen Tao

 

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

manikumar34
Super User I
Super User I

It is better to create in Excel or SQL.

 

Regards, 

Manikumar





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




PaulDBrown
Super User II
Super User II

@greeshma 

Probably simpler to create the table in Excel and import it, no?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors