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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic calculations basis Date selection

Objective:- Dynamic calculations basis Date selection

 

Requirement :- Categorise all transactions basis difference between selected date and Due Date of Transaction into different buckets as below

 

- 31-60 : if date difference between selected date and Due Date is >30, categorise it as "31-60"

- 1-30 : if date difference between selected date and Due Date is between 1-30, categorise it as "1-30"

- Current : if date difference between selected date and Due Date is <= 0, categorise it as "Current"

Create a 100% stacked bar, showing bucket-wise Net Amount

 

Scenario :- Date selected - 31/01/19image.png

 

Refer this data

 

Screenshot (393).png

 

1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

It’s my pleasure to answer for you.

According to your description, I think you can create a calendar table to filter date, then create three similar measures,put them in 100% stacked bar chart.

Like this:

1-30 = 
SUMX (
    FILTER (
        ADDCOLUMNS (
            'Table',
            "age",
                VAR selecteddate =
                    SELECTEDVALUE ( 'Table 2'[Date] )
                VAR duedate =
                    IF ( [Due Date] = BLANK (), TODAY (), [Due Date] )
                RETURN
                    SWITCH (
                        TRUE (),
                        duedate - selecteddate > 30, "31-60",
                        duedate - selecteddate >= 0
                            && duedate - selecteddate < 30, "1-30",
                        duedate - selecteddate < 0, "Current",
                        BLANK ()
                    )
        ),
        [age] = "1-30"
    ),
    [Net Amount]
)

6.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , where is Due Date ?

You can have a measure like this keep the smaller date before

 

Days = datediff(Selectedvalue(Date[Date]), max(Table[Due Date]), day)

 

Need a context to sum or Avg

Sumx(values(Table[Customter]),[Days])

 

For bucket refer my video on dynamic segmentation : https://www.youtube.com/watch?v=CuczXPj0N-k

 

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
Anonymous
Not applicable

Sorry my bad, mentioned the wrong dataset

Screenshot (394).png

 

Hi, @Anonymous 

 

It’s my pleasure to answer for you.

According to your description, I think you can create a calendar table to filter date, then create three similar measures,put them in 100% stacked bar chart.

Like this:

1-30 = 
SUMX (
    FILTER (
        ADDCOLUMNS (
            'Table',
            "age",
                VAR selecteddate =
                    SELECTEDVALUE ( 'Table 2'[Date] )
                VAR duedate =
                    IF ( [Due Date] = BLANK (), TODAY (), [Due Date] )
                RETURN
                    SWITCH (
                        TRUE (),
                        duedate - selecteddate > 30, "31-60",
                        duedate - selecteddate >= 0
                            && duedate - selecteddate < 30, "1-30",
                        duedate - selecteddate < 0, "Current",
                        BLANK ()
                    )
        ),
        [age] = "1-30"
    ),
    [Net Amount]
)

6.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

themistoklis
Community Champion
Community Champion

@Anonymous 

In a new column add the following formula to create the groups.

Then on the chart add the column and the net amount 

 

Column = 
var _selecteddate = SELECTEDVALUE('Calendar'[Date])
return
SWITCH (
    TRUE (),
    'Table'[Due_date] - _selecteddate > 30, "31-60",
    'Table'[Due_date] - _selecteddate >= 0 && 'Table'[Due_date] - _selecteddate < 30 , "0-30",
    'Table'[Due_date] - _selecteddate < 0, "Current",	
    BLANK()
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.