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
spartan27244
Helper II
Helper II

Mutiple date replatioships or reporting periods

I'm trying to figuree out how to best handle multiple customer defined reporting periods. In a typical secario a customer will have their benefit year defined as Sept - Aug, and I will have a table in my SQL database for each year 2016, 2017, 2018, etc. in addition, that same customer my have an additional reporting periods all with different start and end dates and over multiple years. Now multiply that over many customers. How can I represent this in PowerBI. I am currently doing this as a table that has an Id to represent the customer, A name for the period i.e. 2016 BY, 2017 BY... and a date column populated with every day from the beginning to the end of the period. This of course creates a many to many relationship, and cannot be marked as a DATE table. Looking for ways around this before it becomes something that cannot be managed. Thanks

1 ACCEPTED SOLUTION
spartan27244
Helper II
Helper II

After many hours and some luck I finally figured it out. Step one is to create a standard Date table to filter your data, then relate the date table to you report period dates. Boom!

View solution in original post

7 REPLIES 7
spartan27244
Helper II
Helper II

After many hours and some luck I finally figured it out. Step one is to create a standard Date table to filter your data, then relate the date table to you report period dates. Boom!

v-yangliu-msft
Community Support
Community Support

Hi  @spartan27244  ,

Here are the steps you can follow:

1. Create calculated table.

Date = CALENDARAUTO()

2. Create measure.

Flag =
var _min=MIN('Date'[Date])
var _max=MAX('Date'[Date])
return
IF(_min>=MAX('Table'[StartDate])&&_max<+MAX('Table'[EndDate]),1,0)

3. Use the Date column of the Date table as the slicer, put measure[Flag] into the Filter, and select is = 1

v-yangliu-msft_0-1620784073691.png

4. Result:

When the slicer dates are 2016-03-21 and 2016-09-18, the following results are displayed in the visual object:

v-yangliu-msft_1-1620784073712.jpeg

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

spartan27244
Helper II
Helper II

One idea that I thought of was use a slicer to allow the user to select the report period in the  period table then use that to get SelectedValue of the Start and End Date and then supply these values to a Date Slicer as a beginning and end date. However I do not know of a way to populate a visual with data based another's visual's selection

ChrisMendoza
Resident Rockstar
Resident Rockstar

@spartan27244 - sounds like you have a similar need to https://community.powerbi.com/t5/Desktop/Multiple-Calendars-for-Multiple-Companies/m-p/901130#M43190... . Try that method.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



I cannot tell from that post that anything was solved, and I do not see an actual solution. Looks like the poster simply marked their own comment as a solution.

spartan27244
Helper II
Helper II

The data does not just pertain to one customer, that is a different filter. The report is not just loaded for one customer, but for all, so the user must be able to put in parameters to provide rport periods, or we must be able to adapt the ones defined in our normal SQL database.  In our SQL database it looks like this.

 

     
PeriodIdPopulationIdPeriodNameStartDateEndDate
1A2016-BY9/1/20168/31/2017
2A2017-BY9/1/20178/31/2018
3B2019 -FY3/1/20162/28/2017
4C2018-CY1/1/201812/31/2018

 

So as you can see from above each period has a unique key, the a book of business has a key (PopulationId) and there are varying Start and End Dates. Each Book of busienss is owned by a customer and a single customer can have many populations. So to represent this as a simple date table with "tags" for the data ranges is almost impossible. Currenty I am joining this table to a date table to produce all of the multiple dates in the ranges for each period row above. This leades to a table with M-M relationships.

ChrisMendoza
Resident Rockstar
Resident Rockstar

@spartan27244 - The 'date' is still a date though. Each of your customers just report it how they need. So you could just create Calculated Columns in PBI or use Power Query Custom Columns before you load to PBI.

Essentially you would be doing something like:

psuedo-SWITCH; the if monthNum = #, then newMonthName

This shows how I'm moving MonthNum = 1 ('Jan') to newMonthName = ('Jul')

  {1, "Jul"},
  {2, "Aug"},
  {3, "Sep"},
  {4, "Oct"},
  {5, "Nov"},
  {6, "Dec"},
  {7, "Jan"},
  {8, "Feb"},
  {9, "Mar"},
  {10, "Apr"},
  {11, "May"},
  {12, "Jun"},
  {input, "Undefined"}

 You can do similiar logic for Fiscal Years

if [MonthNum] >= 7 then Date.Year([Date]) - 1 else Date.Year([Date])

I only have Power Query example but the technique could be transferred to DAX.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



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.