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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ShibuyaSoo
Frequent Visitor

Hierarchy Date Parent-Child Categorical

Hi guys, need help to fix my problem. My date is based on day start with Friday and end on Thursday

 
Date Week Starts Friday =
  VAR Friday = WEEKDAY('Calendar'[Date], 2)
  RETURN 'Calendar'[Date] + IF(Friday > 4, 5, -2) - Friday
 
However, when I create a hierarchy slicer with just regular date to be its child. There are few months that have Parent (belong to previous month) but Child (current month). How can I fix the parent date name follow child date
 
ShibuyaSoo_0-1715065003112.png

 

 
1 ACCEPTED SOLUTION

@ShibuyaSoo You can add a column with this DAX and use it as the parent.

Date Week Starts Friday 2 = 
  VAR Friday = WEEKDAY('Calendar'[Date], 2)
  VAR weekStartDate = 'Calendar'[Date] + IF(Friday > 4, 5, -2) - Friday
  RETURN MAX(weekStartDate, STARTOFMONTH('Calendar'[Date]))

vjingzhanmsft_0-1715155100587.png

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

 

View solution in original post

5 REPLIES 5
ShibuyaSoo
Frequent Visitor

@v-jingzhan-msft ,Yes your result same as mine, my idea is to change the parent name follow with min date of its child. For example from your result:

 

March : 3/29/2024 (Parent) : 29/30/31 (Child)

April : 3/29/2024 (Parent) : 1/2/3/4 (Child)

 

is it possible on April, Parent name follow the min date of its child?. Because I saw the date patern for example Feb to Mar they do not have issue with financial date, Parent name = min date child.

@ShibuyaSoo You can add a column with this DAX and use it as the parent.

Date Week Starts Friday 2 = 
  VAR Friday = WEEKDAY('Calendar'[Date], 2)
  VAR weekStartDate = 'Calendar'[Date] + IF(Friday > 4, 5, -2) - Friday
  RETURN MAX(weekStartDate, STARTOFMONTH('Calendar'[Date]))

vjingzhanmsft_0-1715155100587.png

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

 

@v-jingzhan-msft , I tried & test with the data, It's working well for me & kudos to you bro 👏👍

v-jingzhan-msft
Community Support
Community Support

Hi @ShibuyaSoo 

 

This is due to that you are using the regular Month column as the parent of "Date Week Starts Friday" column in the slicer. I can reproduce the same behavior as below. I think this is the correct result based on the current selected columns. 

vjingzhanmsft_0-1715137045428.png

 

If you want to fix the parent date name, you need to have an additional column to have those fix names. Then use the fix column as the parent of regular date in the slicer. But if you do that, the fix week start dates for some weeks may not be their correct week start dates as the correct ones do exist in previous month. For 1/4/2024 ~ 4/4/2024, you want to fix their week start date to which date? 1/4/2024 or some other date?

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

 

Ritaf1983
Super User
Super User

Hi @ShibuyaSoo 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.