March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi Experts
I am trying to sum the range of data as shown in the image below.
The Sum only applies to the last for Periods as Shown in the image..
See attached PBIX where i can add single cell - how do you sum a range of cell as shown above
Sample PBIX
https://www.dropbox.com/s/bko95z5uckgj9j3/sample%283%29.pbix?dl=0
Solved! Go to Solution.
Tricky Sum =
VAR __inteval = DATESINPERIOD( DATES[Date], MAX( DATES[Date] ), -3, MONTH )
RETURN
IF(
MIN( DATES[Date] )
>= EDATE( CALCULATE( MIN( DATES[Date] ), ALL() ), COUNTROWS( SPAN ) + 1 ),
SUMX(
DISTINCT( SPAN[Inteval] ),
VAR __i = SPAN[Inteval]
RETURN
CALCULATE(
SUM( 'SAMPLE'[Value] ),
'SAMPLE'[Attribute] = __i,
DATEADD( __inteval, - SPAN[Inteval], MONTH )
)
)
)
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Tricky Sum =
VAR __inteval = DATESINPERIOD( DATES[Date], MAX( DATES[Date] ), -3, MONTH )
RETURN
IF(
MIN( DATES[Date] )
>= EDATE( CALCULATE( MIN( DATES[Date] ), ALL() ), COUNTROWS( SPAN ) + 1 ),
SUMX(
DISTINCT( SPAN[Inteval] ),
VAR __i = SPAN[Inteval]
RETURN
CALCULATE(
SUM( 'SAMPLE'[Value] ),
'SAMPLE'[Attribute] = __i,
DATEADD( __inteval, - SPAN[Inteval], MONTH )
)
)
)
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi CNENFRNL..... How would you do the following - since you original solution was stop on
https://community.powerbi.com/t5/Desktop/TRICKY-Diagonal-Sum-to-Sum-a-Range-of-Data/m-p/1939347#M738...
Hi CNENFRNL.... could you kindly have a look at the following please..... stuck and unable to find a solution.
https://community.powerbi.com/t5/Desktop/TRICKY-Average-last-6-5-4-and-3-months/m-p/1936148#M737666
Many Thanks to all experts
@Anonymous interesting, solution attached.
Sum by Attribute =
CALCULATE (
SUM ( 'Sample Data'[Value] ),
DATESINPERIOD (
'Calendar'[Date],
EOMONTH (
MAX ( 'Calendar'[Date] ),
MAX ( 'Sample Data'[Attribute] ) * -1
),
-3,
MONTH
)
)
Measure 2 =
SUMX (
SUMMARIZE (
'Sample Data',
'Calendar'[Month],
'Sample Data'[Attribute]
),
[Sum by Attribute]
)
Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous is this the expected output?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi Parry
The expected output would be a simple table like this as similir to the table in the PBIX File,
Feb-20 | |
Mar-20 | |
Apr-20 | |
May-20 | |
Jun-20 | |
Jul-20 | |
Aug-20 | |
Sept-20 | |
Oct-20 | 147.2 |
Nov-20 | 152.9 |
Dec-20 | 148.2 |
Jan-21 | 162.5 |
The ranges highlighted and the sum formula gives Oct-20.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
82 | |
69 | |
53 | |
44 |
User | Count |
---|---|
202 | |
106 | |
100 | |
64 | |
56 |