Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello everyone
I have a problem when making a cumulative sum, I explain, I have a table with a quantity and two fields date, from and to, I want to make the cumulative sum of the amount (which is always fixed) considering that the date up may be less, I have set as end date 31/12/2050 those that have not yet ended.
the table is more or less like this
id cant start date end date
1 5 01/01/2018 30/06/2019
2 10 05/05/2018 31/12/2050
3 100 01/05/2019 31/12/2050
4 25 10/06/2019 01/01/2020
5 50 10/05/2020 31/12/2050
And I'm looking for an annual cumulative result of the total so
2018 15 (id 1+2)
2019 135 (id 1+2+3+4 - 1)
2020 160 (id 1+2+3+4+5 - 1 -4)
Thanks a lot
Solved! Go to Solution.
@JmSahuco Do you have a DimDate table? Is it unrelated to the table with Cant, ID, in it?
You can try something like:
Total Measure =
VAR _MinDate = MIN(DimDate[Date])
VAR _MaxDate = MAX(DimDate[Date])
RETURN
SUMX(FILTER(Table), Table[StartDate] <= _MaxDate && Table[EndDate] >= _MinDate), Table[Cant])
Then put DimDate values in the visualization along with the measure above.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi,
You may download my PBI file from here.
Hope this helps.
@JmSahuco Do you have a DimDate table? Is it unrelated to the table with Cant, ID, in it?
You can try something like:
Total Measure =
VAR _MinDate = MIN(DimDate[Date])
VAR _MaxDate = MAX(DimDate[Date])
RETURN
SUMX(FILTER(Table), Table[StartDate] <= _MaxDate && Table[EndDate] >= _MinDate), Table[Cant])
Then put DimDate values in the visualization along with the measure above.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Me ha servido mucho la solución, sólo he tenido que realizar un ligero cambio
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
85 | |
70 | |
68 | |
50 | |
32 |
User | Count |
---|---|
117 | |
100 | |
73 | |
65 | |
40 |