Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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
Solved! Go to Solution.
Hi @Anonymous ,
Indeed, it will be a little troublesome to use dax.
1.Create a calendar table and a category table.
Table = CALENDAR(DATE(2020,1,1),DATE(2021,12,31))
2.Create a relationship between calendar table and main table.
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.
Hi @Anonymous ,
Indeed, it will be a little troublesome to use dax.
1.Create a calendar table and a category table.
Table = CALENDAR(DATE(2020,1,1),DATE(2021,12,31))
2.Create a relationship between calendar table and main table.
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.
It is better to create in Excel or SQL.
Regards,
Manikumar
Proud to be a Super User!
@Anonymous
Probably simpler to create the table in Excel and import it, no?
Proud to be a Super User!
Paul on Linkedin.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
123 | |
78 | |
48 | |
38 | |
37 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |