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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
PaulGBG
Frequent Visitor

Create date bins from a date variable

Hi,

 

I need to set up a report that uses a date variable from a slicer input to show customer outstanding amounts as at the date selected, and also grouped in dates 31 days from that date variable. 

 

I have the correct total $ amounts from a measure using the date variable.

 
Test Var 2 =
VAR RunDate22 = min('As at Date'[Due Date])
RETURN
CALCULATE(SUM('Detailed_Customer_ledger_entries'[Amount_LCY]),
(RunDate22 >= 'Detailed_Customer_ledger_entries'[Posting_Date])
)
 
I have been trying to use the same date variable in a calculated column to get the date bins, when I had a fixed date, I could do this using IF formulas that refer to the following calculated column (as below), the date variable didn't seem to work in a calculated column though to replace  DATE (2020,08,31).
 
Due Date Days = (1.* 'Cust_LedgerEntries'[Due_Date]- DATE(2020,08,31))*-1
 
I have been trying to put an IF statement in the measure just before the RETURN statement, but I couldn't get this to work.
 
So I would need one measure for all days that are between 1 and 31 days where the due date is older than the variable date for example.
 
What is the best way to do this please?
 
1 ACCEPTED SOLUTION

Thanks for helping 

 

Actually I just resolved this myself. The filters are within calculate, so all I needed to do was add in:

 

VAR RunDate22 = min('As at Date'[Due Date])
RETURN
CALCULATE(SUM('Detailed_Customer_ledger_entries'[Amount_LCY]),
(RunDate22 >= 'Detailed_Customer_ledger_entries'[Posting_Date]),
(RunDate22 - 'Cust_LedgerEntries'[Due_Date])>31,
(RunDate22 - 'Cust_LedgerEntries'[Due_Date])<63
)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@PaulGBG ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for helping 

 

Actually I just resolved this myself. The filters are within calculate, so all I needed to do was add in:

 

VAR RunDate22 = min('As at Date'[Due Date])
RETURN
CALCULATE(SUM('Detailed_Customer_ledger_entries'[Amount_LCY]),
(RunDate22 >= 'Detailed_Customer_ledger_entries'[Posting_Date]),
(RunDate22 - 'Cust_LedgerEntries'[Due_Date])>31,
(RunDate22 - 'Cust_LedgerEntries'[Due_Date])<63
)

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors