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])
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!