The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello guys,
I need to get last 4 measures from column (measures) by date (there could be more measures in one day).
Can anybody help me how to use DAX to get it ?
Thank you in advance
Solved! Go to Solution.
Hi,
According to your description, I can roughly understand your requirement, you want to filter the data table to show you the trend for the last 4 values and not use the Top N function, right? I think you can try this method:
This is the test data I created based on your description:
You can create the rank column like this:
Rank = RANKX('Table',[Date],,DESC,Dense)
Then you can create a calculated table like this:
last 4 values =
SELECTCOLUMNS(FILTER('Table','Table'[Rank]<=4),"Date",'Table'[Date],"measurements",'Table'[measurements])
And you can create a line chart to place it like this to get what you want.
You can download my test pbix file below
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Thank you very much!
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
According to your description, I can roughly understand your requirement, you want to filter the data table to show you the trend for the last 4 values and not use the Top N function, right? I think you can try this method:
This is the test data I created based on your description:
You can create the rank column like this:
Rank = RANKX('Table',[Date],,DESC,Dense)
Then you can create a calculated table like this:
last 4 values =
SELECTCOLUMNS(FILTER('Table','Table'[Rank]<=4),"Date",'Table'[Date],"measurements",'Table'[measurements])
And you can create a line chart to place it like this to get what you want.
You can download my test pbix file below
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Thank you very much!
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , Last for measures?
if you need rolling
Rolling 4= CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-4,Day))
The information you have provided is not making the problem clear to me. Can you please explain with an example.
Appreciate your Kudos.
Hello @amitchandak ,
I have column with measurements (numbers between 0 -5) which are each day updated with new neasurements. I have to add Sparkline to my table which show me trend for last 4 values. I can't use filter Top N, because I'm using rank function.
I need probably create a new value(column) where I will have always only last 4 measurements from column "measurements".
I hope I make it more clear now.
Thank you in advance
User | Count |
---|---|
27 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
7 | |
7 |