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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Stop showing running total in yearly comparison graph

Hello dear community, 

 

I'm currently using the following graph to show the YoY progession of a running total: 

 

BRUNOLUIS_0-1618559762319.png

I would like that the running total dissapears for the future dates further "today's" date. I'm using this formula, since I want also that running total resets each year: 

 

 

 

CUMUL ANOMALIES = CALCULATE (
    SUM('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES]), FILTER (
        ALL ('dwh dim_Date' ),
        'dwh dim_Date'[Date] <= MAX('dwh dim_Date'[Date])
        && 'dwh dim_Date'[Year] = MAX ('dwh dim_Date'[Year] )))

 

 

 

I appreciate any help on the subject. Thanks in advance 😄 !! 

11 REPLIES 11
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

Can you please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hello, here is the data I'm using: 

 

YearMonthANOMALIES
2019January4
2019February1
2019March2
2019April1
2019May5
2019June3
2019July1
2019August3
2019September2
2019October5
2019November15
2019December1
2020January6
2020February4
2020March2
2020April 
2020May1
2020June3
2020July9
2020August2
2020September1
2020October3
2020November7
2020December1
2021January1
2021February5
2021March6
2021April4
2021May 
2021June 
2021July 
2021August 
2021September 
2021October 
2021November 
2021December 

 

If I plot the number of anomalies per month, I get the following, which is ok: 

 

BRUNOLUIS_0-1618921919537.png

 

 

However, when I create a running total formula to see the Yearly comparison, I get that my plot for 2020 is discontinuous in April, since there were no recorded anomalies on that month (as we can see in the data): 

 

BRUNOLUIS_1-1618921919928.png

 

 

 

Is there a way so the graph could continue in a constant line for april instead of having an empty space ? I'm using the following running total: 

 

CUMUL ANOMALIES = var today = TODAY()
return
if(max('dwh fac_CountAnomaliesPerMonthRespStatus'[DATE]) <= today , CALCULATE (
sum('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES]), FILTER (
ALL ('dwh fac_CountAnomaliesPerMonthRespStatus'),
'dwh fac_CountAnomaliesPerMonthRespStatus'[DATE] <= max('dwh fac_CountAnomaliesPerMonthRespStatus'[DATE])
&& 'dwh fac_CountAnomaliesPerMonthRespStatus'[YEAR] = max('dwh fac_CountAnomaliesPerMonthRespStatus'[YEAR] ))))

 

Thank you so much for your help !

Hi @Anonymous,

I'd like to suggest you to move the condition into the calculation or it will replace the not matched calculation ranges to blank:

CUMUL ANOMALIES =
CALCULATE (
    SUM ( 'dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES] ),
    FILTER (
        ALL ( 'dwh fac_CountAnomaliesPerMonthRespStatus' ),
        'dwh fac_CountAnomaliesPerMonthRespStatus'[DATE]
            <= MAX ( 'dwh fac_CountAnomaliesPerMonthRespStatus'[DATE] )
            && 'dwh fac_CountAnomaliesPerMonthRespStatus'[YEAR]
                = MAX ( 'dwh fac_CountAnomaliesPerMonthRespStatus'[YEAR] )
            && 'dwh fac_CountAnomaliesPerMonthRespStatus'[DATE] <= TODAY ()
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hello, 

 

thanks for your help. Nevertheless, It still shows the blank on the graph.

 

Cheers, 

HI @Anonymous,

Can you please share a sample pbix file with some dummy data to test? It should help us clear why the formula not works.

Notice: please not attach sensitive data to it.

BTW, did you apply any filters on it? Its filter effect based on current row content, so it will change if you use a filter to break current row contents or replace the axis with other table categories. 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
HarishKM
Impactful Individual
Impactful Individual

@Anonymous  Hey ,YOu can use hasonevalue function to fulfil your requirement .

 

Measure = if(Hasonevalue([table[sales])<>Blank() , CALCULATE (
SUM('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES]), FILTER (
ALL ('dwh dim_Date' ),
'dwh dim_Date'[Date] <= MAX('dwh dim_Date'[Date])
&& 'dwh dim_Date'[Year] = MAX ('dwh dim_Date'[Year] ))), Blank() )
Try that and let me know .

 

 

Kudos will be appriciated 

HarishKM
Impactful Individual
Impactful Individual

@Anonymous  Hey 

Try this 

 Test = if(SUM('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES])<>0,CALCULATE (
SUM('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES]), FILTER (
ALL ('dwh dim_Date' ),
'dwh dim_Date'[Date] <= MAX('dwh dim_Date'[Date])
&& 'dwh dim_Date'[Year] = MAX ('dwh dim_Date'[Year] ))), Blank() )

 

Kudos will be appriciated 

Anonymous
Not applicable

Hello again, 

 

same result. I'm guessin that if there is not variation of the value from one month to another, the line is not plotted then. 

 

 

Anonymous
Not applicable

Hello HarishKM,

 

Thanks for your answer. It works for the current year, however it is affecting past year values: 

 

BRUNOLUIS_0-1618565109912.png

Do you know the reason ? I'm using this: 

 

Measure = if(Hasonevalue('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES])<>Blank() , CALCULATE (
SUM('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES]), FILTER (
ALL ('dwh dim_Date' ),
'dwh dim_Date'[Date] <= MAX('dwh dim_Date'[Date])
&& 'dwh dim_Date'[Year] = MAX ('dwh dim_Date'[Year] ))), Blank() )

 

Thanks ! 

amitchandak
Super User
Super User

@Anonymous , refer these example code, how to control ,YTD based on Today

 

YTD QTY forced=
var _max = today()
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

 

LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

Anonymous
Not applicable

Hello amitchandak, 

 

thank you so much for your quick answer, that helped me a lot! Thought, the graph is now showing until last month: 

 

BRUNOLUIS_2-1618561480976.png

 

Could you help me to show data until today? I'm using first option you proposed: 

 

YTD QTY forced = 
var _max = today()
return
if(max('dwh dim_Date'[Date])<=_max, calculate(Sum('dwh fac_CountAnomaliesPerMonthRespStatus'[ANOMALIES]), DATESYTD('dwh dim_Date'[Date].[Date])), blank())

 

Many thanks ! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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