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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
mateoc15
Advocate II
Advocate II

Multiple Dates in Cube Table - relationship to Date table

I need help with relationships betwen multiple dates in a single table and a date dimension table.  I've found some articles, but nothing quite fits exactly what I'm looking for.  I want to be able to use the Date table as a slicer across multiple visualizations - for instance select 8/1/25 and display both the month of August in one visualization, and display the full year 2025 in another visualzation.

 

For those who don't know, a cube is a model where a single table contains multiple levels of aggregation.  For records where a particular dimension is NOT a part of the aggregation it's just null.  In a PBI report, if I wanted to see total records for category P all time I would filter to category = P, subcategory is null, beginning of month is null, and beginning of year is null.

Rowcategorysubcategorybeginning of monthbeginning of yeartotal_recordsunique_usersCOMMENT
1NULLNULLNULLNULL8388748689293no grouping, everything ever all time
2PNULLNULLNULL30029258746aggregated only by category P
3MNULLNULLNULL3971823435387aggregated only by category M
4ANULLNULLNULL9766816062aggregated only by category A
5CNULLNULLNULL30220953729aggregated only by category C
6XYNULLNULL8361178172947aggregated by category X and subcategory Y, nothing else
7NULLNULLNULL1/1/20243413517842aggregated by year (2024)
8MG3/1/20251/1/20253971823435387aggregated by category M, subcategory G, year 2025, month 3/25
9NULLNULL8/1/20251/1/20258355225687139aggregated by year (2025) and month 8/25
10PNULLNULL1/1/202530029258746aggregated by category P, year 2025
11CNULLNULL1/1/202530220953729aggregated by category C, year 2025


I have two dates in the cube table.  One is for month (which is the date of the first of the month), and one is year (which is Jan 1 of the year).  I have created the relationships and am using WITHRELATIONSHIP in my measures.  My date table includes one record per day, and also includes a date for first of the month and first of the year.  I'm wondering if the relationship of the cube to date table should be Date.Date (current setup) or Date.FirstOfMonth (which seems to cause more problems since there are about 30 date table records for each FirstOfMonth).  My defined relationships are

Date.Date = CubeTable.BeginningOfMonth
Date.Date = CubeTable.BeginningOfYear


Measures:

Unique Members by Month =
calculate(
    sum('App Cube'[unique_members]),
    USERELATIONSHIP('App Cube'[first of month], Dates[Date])
)
Unique Members by Year =
calculate(
    sum('App Cube'[unique_members]),
    USERELATIONSHIP('App Cube'[first of year], Dates[Date])
)
 
Any help is greatly appreciated!  Thanks.
1 ACCEPTED SOLUTION

Here’s the refined version of your measure:

Unique Members by Month =
CALCULATE(
    SUM('App Cube'[unique_users]),
    USERELATIONSHIP('App Cube'[BeginningOfMonth], Dates[Date])
)

 

Unique Members by Year =
CALCULATE(
    SUM('App Cube'[unique_users]),
    USERELATIONSHIP('App Cube'[BeginningOfYear], Dates[Date])
)


If you want dynamic switching (Month vs Year) in one measure, use:

Unique Members Dynamic =
SWITCH(
    TRUE(),
    SELECTEDVALUE(Dates[Granularity]) = "Month",
        CALCULATE(SUM('App Cube'[unique_users]), USERELATIONSHIP('App Cube'[BeginningOfMonth], Dates[Date])),
    SELECTEDVALUE(Dates[Granularity]) = "Year",
        CALCULATE(SUM('App Cube'[unique_users]), USERELATIONSHIP('App Cube'[BeginningOfYear], Dates[Date]))
)

View solution in original post

3 REPLIES 3
v-nmadadi-msft
Community Support
Community Support

Hi @mateoc15 

May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.


Thank you

v-nmadadi-msft
Community Support
Community Support

Hi @mateoc15 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.


Thank you.

Here’s the refined version of your measure:

Unique Members by Month =
CALCULATE(
    SUM('App Cube'[unique_users]),
    USERELATIONSHIP('App Cube'[BeginningOfMonth], Dates[Date])
)

 

Unique Members by Year =
CALCULATE(
    SUM('App Cube'[unique_users]),
    USERELATIONSHIP('App Cube'[BeginningOfYear], Dates[Date])
)


If you want dynamic switching (Month vs Year) in one measure, use:

Unique Members Dynamic =
SWITCH(
    TRUE(),
    SELECTEDVALUE(Dates[Granularity]) = "Month",
        CALCULATE(SUM('App Cube'[unique_users]), USERELATIONSHIP('App Cube'[BeginningOfMonth], Dates[Date])),
    SELECTEDVALUE(Dates[Granularity]) = "Year",
        CALCULATE(SUM('App Cube'[unique_users]), USERELATIONSHIP('App Cube'[BeginningOfYear], Dates[Date]))
)

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.