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
Hello,
Can anyone help me to calculate last n days data but it should not consider the current date in calculation.
Thank you.
Solved! Go to Solution.
Hi,
I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your datamodel.
The disconnected table shown in the below is created by using Numeric range new parameter feature.
Value total: =
SUM( Data[Value] )
Last N days value total: =
VAR _Ndays = [LastNdays Value]
VAR _window =
WINDOW (
- _Ndays,
REL,
-1,
REL,
ALL ( 'Calendar'[Date] ),
ORDERBY ( 'Calendar'[Date], ASC )
)
RETURN
IF ( COUNTROWS ( _window ) >= _Ndays, CALCULATE ( [Value total:], _window ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your datamodel.
The disconnected table shown in the below is created by using Numeric range new parameter feature.
Value total: =
SUM( Data[Value] )
Last N days value total: =
VAR _Ndays = [LastNdays Value]
VAR _window =
WINDOW (
- _Ndays,
REL,
-1,
REL,
ALL ( 'Calendar'[Date] ),
ORDERBY ( 'Calendar'[Date], ASC )
)
RETURN
IF ( COUNTROWS ( _window ) >= _Ndays, CALCULATE ( [Value total:], _window ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Measure = calculate(TOPN(<N_Value>, <Table>, <OrderBy_Expression>, [<Order>[, <OrderBy_Expression>, [<Order>]]…]),table[date]<MAX(table[date]))
@msp_25 If this post helps, please consider accept as solution to help other members find it more quickly.
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 |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
105 | |
99 | |
64 | |
54 |