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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rpinxt
Impactful Individual
Impactful Individual

Showing a correct YTD by month if 1 month has no action

I have this small example data table:

PostingDateEoMMaterialQuantity
12-01-2131-01-21abc50
23-01-2131-01-21abc75
08-02-2128-02-21abc25
25-02-2128-02-21abc100
01-04-2130-04-21abc200
29-04-2130-04-21abc65
15-01-2231-01-22abc150
17-01-2231-01-22abc35
10-02-2228-02-22abc85
15-02-2228-02-22abc115
03-04-2230-04-22abc155
19-04-2230-04-22abc95
05-03-2131-03-21def10
05-03-2231-03-22def35

 

Now I created a YTD measure and want to show it over time by period (for now I put it in a matrix):

rpinxt_0-1665136475884.png

So the problem here is that period 3 shows no data for material abc.

All the numbers are fine and also the total is fine but I would like to have period 3 populate despite that there was no action.

 

What period 3 should show is the same ending balance as period 2.

So that when you would put things in a chart there would not be a broken line or en empty bar/column.

 

Guess if it is possible it would need to be done by DAX.

So how would I tell it to show the same YTD end balance as previous month if nothing happend in the "current" month?

 

This is my YTD measure now:

YTD Qty =
VAR MaxDate = MAX(Sheet1[EoM])
VAR Result =
    CALCULATE(
        SUM(Sheet1[Quantity]),
        Sheet1[EoM] <= MaxDate,
        ALL(Dim_Date)
    )
RETURN
    Result
2 ACCEPTED SOLUTIONS

@rpinxt 

Try this.

Total = CALCULATE(SUM('Table'[Quantity]), FILTER(ALLEXCEPT(Calender,'Calender'[Date].[Year]), 'Calender'[Date] <= MAX('Calender'[Date])))

Dinesh_Suranga_0-1665146068367.png

 

View solution in original post

Yes I think I again was using something similar which seems to work the same:

Test2 = CALCULATE(SUM(Sheet1[Quantity]),FILTER(ALLSELECTED(Dim_Date),Dim_Date[Date] <= MAX(Dim_Date[Date])))
 
Thanks for helping me along 🙂

View solution in original post

8 REPLIES 8
rpinxt
Impactful Individual
Impactful Individual

Hi @Dinesh_Suranga ,

 

Nope tried that. That does not work :

rpinxt_0-1665143509921.png

Just adds a lot of extra empty columns.

And you cannot use the "select items with no data" on a measure.

@rpinxt 

Hi,

Do you use a seperate calender table?

Thank you

 

Yes I do.

@rpinxt 

Try following DAX.

YTD = TOTALYTD(SUM('Table'[Quantity]), Calender[Date])

Dinesh_Suranga_0-1665145132800.png

 

 

Yes I was using now the TOTALYTD function:

Test = TOTALYTD(SUM(Sheet1[Quantity]),Dim_Date[Date])
However as you see it resets at the year.
I want it to continue after 2021. It should not reset on Year.

@rpinxt 

Try this.

Total = CALCULATE(SUM('Table'[Quantity]), FILTER(ALLEXCEPT(Calender,'Calender'[Date].[Year]), 'Calender'[Date] <= MAX('Calender'[Date])))

Dinesh_Suranga_0-1665146068367.png

 

Yes I think I again was using something similar which seems to work the same:

Test2 = CALCULATE(SUM(Sheet1[Quantity]),FILTER(ALLSELECTED(Dim_Date),Dim_Date[Date] <= MAX(Dim_Date[Date])))
 
Thanks for helping me along 🙂
Dinesh_Suranga
Continued Contributor
Continued Contributor

@rpinxt 

Hi,

Tick

Select items with no data.

Thank you.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.