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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Ormesome
Helper II
Helper II

You are X days into the Y

Given the following schema

 

Table: Calendar

  • Date
  • Week Number
  • Fortnight Number
  • Month Number

Table: GoogleAnalytics

  • Date
  • Web Page
  • Number Of Pageviews

where the 2 tables join on the Date fields,

 

How do I display

  • "you are 2 days into the week"?
  • "you are 9 days into the fortnight"?
  • "you are 31 days into the month"?

I've also been asked to divide the year into other arbitrary time periods (lunar calendar, for example).

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Date math is going to be your best solution here.  Using that you can do things like:

  • Take the Day Of the Week number, adjust it for your starting day, and then build a string using a measure to display the result
  • Take the Date and extract the 'Day value', and then build a string using a measure to display the result
  • Take the week number, check if its divisible by 2 (i.e. even or odd).  This tells you which side of the fortnight you are on, so you can produce a different number to when you are on the other side of the fortnight.

 

You can use measures within measures, so in your fortnight calculation, you can use the result of your weekly calculation.  Once you have all the numbers you need, you can create the Text display measures that look something like

Display Week = "You are " & [WeekAmount] & " days into the week."

 

View solution in original post

3 REPLIES 3
Eric_Zhang
Microsoft Employee
Microsoft Employee


@Ormesome wrote:

Given the following schema

 

Table: Calendar

  • Date
  • Week Number
  • Fortnight Number
  • Month Number

Table: GoogleAnalytics

  • Date
  • Web Page
  • Number Of Pageviews

where the 2 tables join on the Date fields,

 

How do I display

  • "you are 2 days into the week"?
  • "you are 9 days into the fortnight"?
  • "you are 31 days into the month"?

I've also been asked to divide the year into other arbitrary time periods (lunar calendar, for example).

 

 


@Ormesome

Your questions are not quite clear for me, could you post any sample data and the expected output?

Because the 2 tables are joined there is an implicit context filter on the calendar table. I found it tricky to use DAX to calculate the number of days that have passed this fortnight when there is no data in the GA table for the first 2 days.

 

I have reconsidered the problem and have successfully calculated this in Power Query.

 

Thank you

Anonymous
Not applicable

Date math is going to be your best solution here.  Using that you can do things like:

  • Take the Day Of the Week number, adjust it for your starting day, and then build a string using a measure to display the result
  • Take the Date and extract the 'Day value', and then build a string using a measure to display the result
  • Take the week number, check if its divisible by 2 (i.e. even or odd).  This tells you which side of the fortnight you are on, so you can produce a different number to when you are on the other side of the fortnight.

 

You can use measures within measures, so in your fortnight calculation, you can use the result of your weekly calculation.  Once you have all the numbers you need, you can create the Text display measures that look something like

Display Week = "You are " & [WeekAmount] & " days into the week."

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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