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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
24 | |
20 | |
15 | |
12 |
User | Count |
---|---|
55 | |
48 | |
43 | |
19 | |
19 |