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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
HaHothingoc
Regular Visitor

TotalYTD show 0 value when month value is 0

I have a problem with the TOTALYTD function in Power BI shown below picture:
I create a Measure Rate to calculation ratio of each month = (sum2 column/sum 1 column) *100

Then YTD Rate = TOTALYTD([rate],dim_month[Start of Month]). In the 2023-04 period, YTD rate = 0. The correct result must be equal to the 2023-03 period. Please help me.

 

 

2024-08-14_154734.jpg

2 ACCEPTED SOLUTIONS
SachinNandanwar
Super User
Super User

This ?

SachinNandanwar_1-1723637276536.png
Data >> Table Name : PreviousNonZero
Date,YTD_Rate
01-01-2013,0.50
02-01-2013,0.60
03-01-2013,0.90
04-01-2013,0.00
05-01-2013,1.20
06-01-2013,0.00
07-01-2013,0.00
08-01-2013,0.00
09-01-2013,1.82
10-01-2013,0.00
11-01-2013,0.00
12-01-2013,0.00

 

 

 

 

 

NonZeroValue = 

VAR curr_date =
    MAX ( 'PreviousNonZero'[Date] )
VAR SummarizeVar =
    FILTER (
        SUMMARIZE (
            ALLSELECTED ( 'PreviousNonZero' ),
            'PreviousNonZero'[Date],
            "YTD_Rate", SUM ( 'PreviousNonZero'[YTD_Rate] )
        ),
        [Date] < curr_date
            && [YTD_Rate] <> 0
    )

VAR FilterVar =
    FILTER ( SummarizeVar, [YTD_Rate] >0)

RETURN
    IF (  SUM ( 'PreviousNonZero'[YTD_Rate] ) = 0, MAXX ( FilterVar, [YTD_Rate] ),  SUM ( 'PreviousNonZero'[YTD_Rate] ) )

 

 

 

 

 



Regards,
Sachin
Check out my Blog

View solution in original post

HaHothingoc
Regular Visitor

I have use this formula but the result as below:2024-08-17_140803.jpg

View solution in original post

10 REPLIES 10
HaHothingoc
Regular Visitor

I have use this formula but the result as below:2024-08-17_140803.jpg

Can you share your PBI file ?



Regards,
Sachin
Check out my Blog

I sent the PBI file in a private message. Please check it in your box.

Anonymous
Not applicable

Hi @HaHothingoc 

 

Could you tell me if your problem has been solved?

If it is, kindly Accept it as the solution. More people will benefit from it.

Or you are still confused about it, please provide me with more details about your problem.

 

Best Regards

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

Dear Zhengdong Xu,

 

This issue is not resolved. Mr.Sachin is checking my pbix file.

 

Thanks you.

Hi @HaHothingoc ,

The PBIX file that you shared had problems.

SachinNandanwar_0-1724247639109.png

Please import the data into the file and then share it.

 



Regards,
Sachin
Check out my Blog

Dear Mr.Sachin.

Thank you for your support.
While mirroring data to an Excel file and making a sample to send to you I solved this issue because the relationship in the semantic model is incorrect.

Regards,

SachinNandanwar
Super User
Super User

This ?

SachinNandanwar_1-1723637276536.png
Data >> Table Name : PreviousNonZero
Date,YTD_Rate
01-01-2013,0.50
02-01-2013,0.60
03-01-2013,0.90
04-01-2013,0.00
05-01-2013,1.20
06-01-2013,0.00
07-01-2013,0.00
08-01-2013,0.00
09-01-2013,1.82
10-01-2013,0.00
11-01-2013,0.00
12-01-2013,0.00

 

 

 

 

 

NonZeroValue = 

VAR curr_date =
    MAX ( 'PreviousNonZero'[Date] )
VAR SummarizeVar =
    FILTER (
        SUMMARIZE (
            ALLSELECTED ( 'PreviousNonZero' ),
            'PreviousNonZero'[Date],
            "YTD_Rate", SUM ( 'PreviousNonZero'[YTD_Rate] )
        ),
        [Date] < curr_date
            && [YTD_Rate] <> 0
    )

VAR FilterVar =
    FILTER ( SummarizeVar, [YTD_Rate] >0)

RETURN
    IF (  SUM ( 'PreviousNonZero'[YTD_Rate] ) = 0, MAXX ( FilterVar, [YTD_Rate] ),  SUM ( 'PreviousNonZero'[YTD_Rate] ) )

 

 

 

 

 



Regards,
Sachin
Check out my Blog

Thank you for your support.
 That's exactly my expected result.  The YTD Rate column is a measure and now it has the formula as below:
 YTD Rate = TOTALYTD([rate],dim_month[Start of Month])
 Can we modify the formula of the YTD Rate to get that result or it's just a be created new measure as you provide as above?

Just assign YTD Rate  measure into a variable and use that variable in my measure.



Regards,
Sachin
Check out my Blog

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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