Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreShape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.
Hello all,
I'm fairly new to PBI and am really struggling to get the DAX to enable me to do the following:
I want to build a summary table visualisation like this:
ID | Price (last working day of last week_ | (date) | Highest (Previous Week) | High (date) | Lowest (Previous Week) | Low (date) |
ex1 | 228 | 19/11/2021 | 229 | 18/11/2021 | 213 | 15/11/2021 |
ex2 | 87 | 01/11/2021 | 94 | 18/11/2021 | 213 | 15/11/2021 |
ex3 | 228 | 01/11/2021 | 79 | 18/11/2021 | 213 | 15/11/2021 |
ex4 | 228 | 19/11/2021 | 229 | 18/11/2021 | 213 | 15/11/2021 |
ex5 | 228 | 19/11/2021 | 229 | 18/11/2021 | 213 | 15/11/2021 |
The consolidated table I've built in Power Query which should act as source for this data, looks a bit like this where I have added weekday numbers and week numbers so these can be filtered in the DAX
Date | Price | Week Number | Weekday Number | ID |
10/11/2021 | 34 | 44 | 0 | ex1 |
10/11/2021 | 64 | 44 | 1 | ex1 |
11/11/2021 | 43 | 45 | 0 | ex2 |
11/11/2021 | 57 | 45 | 1 | ex2 |
For the first column, I started with this DAX but it's returning nothing in my table (below). I already have just one column with the different IDs.
Solved! Go to Solution.
Hi @Anonymous
What is [Last Week Number]?
I tried out your expression with this definition:
Last Week Number = MAX('Consolidated IDs'[WEEK_NUMBER])
In that case, the problem is this part:
LastWeekNumber = ('Consolidated IDs'[WEEK_NUMBER] - 1)
It should be a plus, not minus:
LastWeekNumber = ('Consolidated IDs'[WEEK_NUMBER] + 1)
an alternative way of expressing that, which is easier to follow in my opinion:
'Consolidated IDs'[WEEK_NUMBER] = LastWeekNumber - 1
Hi @Anonymous
What is [Last Week Number]?
I tried out your expression with this definition:
Last Week Number = MAX('Consolidated IDs'[WEEK_NUMBER])
In that case, the problem is this part:
LastWeekNumber = ('Consolidated IDs'[WEEK_NUMBER] - 1)
It should be a plus, not minus:
LastWeekNumber = ('Consolidated IDs'[WEEK_NUMBER] + 1)
an alternative way of expressing that, which is easier to follow in my opinion:
'Consolidated IDs'[WEEK_NUMBER] = LastWeekNumber - 1
Thanks Paul. [last week number] = weeknum(today()) - 1
This basically solved my problem, although it opened up another - in the last row of the last column in my table where the date of the lowest price should pull through, it is blank. The dates above it do pull through, it's just this last entry oddly enough.
DAX to pull the date through of the lowest price is:
@Anonymous
You could try using TOPN to get lowest price date:
Low (date) =
VAR _LastWeekNumber = [Last Week Number]
VAR _Lowest =
TOPN(1,
FILTER('Consolidated IDs', 'Consolidated IDs'[WEEK_NUMBER] = _LastWeekNumber - 1),
'Consolidated IDs'[Price],
ASC
)
RETURN
MAXX(_Lowest, 'Consolidated IDs'[Date])
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
20 | |
20 | |
13 | |
12 |
User | Count |
---|---|
41 | |
28 | |
25 | |
23 | |
21 |