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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
skitzo
Frequent Visitor

Solving a date puzzle!

I have 2 tables in PowerBI, "Calendar dim" and "Fact general ledger". I would like to filter the "Fact general ledger" table with a slicer which uses dates from "Calendar dim" table in a way that when i select in slicer 8.3.2015. from example below it filters my "Fact general ledger"  so the result should be like in the table on the far right "Expected general ledger".

 

So the logic should be(in the example below):

  1. when i select 8.3.2015, filter the fact to take all the records where "Document date" between 1.1.2015. and 31.12.2015.
  2. and  "Booking date" <=8.3.2015

 

How can i achieve that by using DAX and relationships? I want to use one date dim to filter fact table on 2 different columns each having it's own logic.

 

Screenshot_1.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Try YEAR(MAX(CalendarTable[Date])) 

View solution in original post

5 REPLIES 5
FilippoV
Helper I
Helper I

I'm according with @Anonymous, but i use this measure:

QtyFact =
VAR MinDate = MIN('CalendarDate'[Date])
VAR MaxDate = MAX('CalendarDate'[Date])
RETURN CALCULATE(SUM('Fact'[Amount]);INTERSECT(VALUES('Fact'[DocumentDate]);DATESBETWEEN('Fact'[DocumentDate]);MinDate;MaxDate)))

 

QtyExp =
VAR MinDate = MIN('CalendarDate'[Date])
VAR MaxDate = MAX('CalendarDate'[Date])
RETURN CALCULATE(SUM('Exp'[Amount]);INTERSECT(VALUES('Exp'[DocumentDate]);DATESBETWEEN('Exp'[DocumentDate]);MinDate;MaxDate)))

Anonymous
Not applicable

You can achieve this by creating a special MEASURE:

1. First, you DO NOT connect your calendar table to the Fact

2. Create a measure:

  Special Sum = CALCULATE(SUM(Amount),Filter(Fact,YEAR(Fact[DocumentDate])=MAX(YEAR(CalendarTable[Date]))&&Fact[BookingDate]<=Max(CalendarTable[Date])))

 

Michael

Hi mshparber,

 

in the part MAX(YEAR(CalendarTable[Date])) i'm getting an error:

"The MAX function only accepts a column reference as an argument"

 

Any ideas?

Anonymous
Not applicable

Try YEAR(MAX(CalendarTable[Date])) 

That works! Thanks

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors