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
CSpina
Helper III
Helper III

undefined

Hi, people.

 

How to calculate acumulative per month using the measure below

 

CSpina_0-1673818506289.png

 

Lost = 
VAR VarCustomerTotal = 
CALCULATETABLE(
    SELECTCOLUMNS(
        dClientes,
        "IDClienteMatriz",
        dClientes[IDCliente]
    ),
    ALL('dCalendário'),
    dClientes[Matriz] = "Não"
)
VAR Result = 
CALCULATETABLE(
    VALUES('fFaturamento Consolidado Churn'[IDClienteMatriz])
    , USERELATIONSHIP('dCalendário'[Data],'fFaturamento Consolidado Churn'[DataUltimaCompraPagamento])
    , PREVIOUSMONTH('dCalendário'[Data])
    , FILTER(
        ALL('dCalendário')
        , 'dCalendário'[Data] < MAX('dCalendário'[Data]) 
    )
)
RETURN
COUNTROWS(EXCEPT(Result, VarCustomerTotal)) 

 

 

 

1 ACCEPTED SOLUTION

Hi @CSpina 

You can try the following code I have modified

Measure 2 = var _addcolumns=ADDCOLUMNS(ALLSELECTED('Table'),"Measure",[Measure])
return SUMX(FILTER(_addcolumns,[Year]=MAX('Table'[Year])&&[Mon_num]<=MAX([Mon_num])),[Measure])

vxinruzhumsft_0-1673918456675.png

Best Regards!

Yolo Zhu

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

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi @CSpina 

You can refer to the following example:

You can create a new column in table first:

Mon_num = SWITCH([Month], 
        "Jan", 1,
        "fev",2,
        "mar",3,
        "abr",4,
        "mai",5,
        "Jun",6,
        "Jul",7, 
        "ago",8,
        "Set",9,
        "out",10,
        "Nov",11,
        "Dez",12
                )

Then create a measure:

Measure 2 = SUMX(FILTER(ALL('Table'),[Year]=MAX('Table'[Year])&&[Mon_num]<=MAX([Mon_num])),[Measure])

Output:

vxinruzhumsft_0-1673834896714.png

Best Regards!

Yolo Zhu

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

 

 

Thanks Yolo.

 

Your solution is very good but due to the calculations in the measure I am getting other results.

 

CSpina_0-1673869348412.png

 

Hi @CSpina 

You can try the following code I have modified

Measure 2 = var _addcolumns=ADDCOLUMNS(ALLSELECTED('Table'),"Measure",[Measure])
return SUMX(FILTER(_addcolumns,[Year]=MAX('Table'[Year])&&[Mon_num]<=MAX([Mon_num])),[Measure])

vxinruzhumsft_0-1673918456675.png

Best Regards!

Yolo Zhu

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

 

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.