Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
NJ81858
Helper IV
Helper IV

Date Table Question

Hello,

 

I have a report that I am showing weekly and monthly information for different metrics. This report refreshes with new data each Friday and will be distibuted via a screenshot sent by email subscription that will send out each Monday Morning.  The weekly information goes from Saturday to Friday, so for example week 1 of 2023 if 12/31/2022 through 1/6/2023. I have the weekly information set up by saying the end of the week is in the last calendar week, so that it will always catch the previous weeks information, my issue is arising in finding out how to calculate the monthly information. 

 

I want to show from the beginning of the month to the most recent week end, except for the first week when the month crosses over to a new month I want to show the prior month total. For an example, for the report that will send out 1/23/2023, I want to show data from January 1 until January 20, as that is my most recent week end. But, for the report that sends out on 2/6/2023, I want to show all of the data for the month of January, as the most recent week as of 2/6 will be 1/28-2/3. I have a measure set up that will look at the most recent week of data and if the month of the start date and the end date are not equal then it will return the month number of the previous month, otherwise it will return the current month. My current measure is set up:

 

VAR _SOW = CALCULATE(MAX('Date Table'[Start of Week]), FILTER('Date Table', [Start of Week] < TODAY()))
VAR _EOW = CALCULATE(MIN('Date Table'[End of Week]), FILTER('Date Table', [End of Week] < TODAY()))

RETURN
IF(MONTH(_SOW) <> MONTH(_EOW), MONTH(EOMONTH(TODAY(), -1)), MONTH(TODAY()))
 
This measure works successfully, I just am stuck on where to go from here to use this measure to filter my table showing monthly data. Thank you in advance!
2 REPLIES 2
Greg_Deckler
Super User
Super User

@NJ81858 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler My Date Table looks something like this:

 

DateStart of WeekEnd of WeekWeekMonthMonth Name
1/4/202312/31/20221/6/2023 12/31/2022 - 1/6/20231January
1/5/202312/31/20221/6/2023 12/31/2022 - 1/6/20231January
1/6/202312/31/20221/6/2023 12/31/2022 - 1/6/20231January
1/7/20231/7/20231/13/20231/7/2023 - 1/13/20231January
1/8/20231/7/20231/13/20231/7/2023 - 1/13/20231January

 

and my expected result will look something similar to this (note this will be the expected result that will distribute on 1/9/2023) :

Weekly Report (for 12/31/2022 - 1/6/2023) :

GroupMetric 1Metric 2
Group 113
Group 246
Group 378

 

Monthly Report (for December) :

GroupMetric 1Metric 2
Group 12555
Group 23060
Group 32070

 

So as you can see, since the start date of the week and the end date of the weekly report are in different months, my monthly report will show the total amount for December, and then for the report that will distribute on 1/23/2022, the weekly report will be for 1/14/2023 - 1/20/2023, and the Monthly Report will be for 1/1/2023 - 1/20/2023, since the start of week and end of week dates are both in the same month, which will show from the beginning of January to most recent date.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.