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've been working with differents measures and I am still stuck.... That's why I wanna ask you guys.
I'm currently working in Slicer where I already have pre-defined the dates (ex: 16/03/2020, 23/03/2020, etc. (7 days difference)) and my idea is to show data from the previous date. The main issues come from when I need to include DAX in my measures. An example of one measure:
My idea is including the previous measure with some DAX which shows me the date from the previous period and not the one which I selected on the Slicer.
Any idea of how to carry out with this?
Many thanks,
One approach would be to use a Date or Calendar table and have one the columns be the "offset" date, so you would not have to calculate it, you could just use it as an attribute of the selected date.
so the "offset" date for 16/03/2020 would be 23/03/2020,
then in any DAX measure where you might use the selected date, you can just substitute using the offset date
Help when you know. Ask when you don't!
The issue comes when I have to include that "approach" into my measures. That's why I set an example with one of my created measures. And I truly prefer to include the solution in a Card insted of a table. Any idea?
Thanks,
I do not see where your sample measure makes any reference to the selected date from the slicer. Does the slicer filter the data you are using in your calcuate() ? If so you would set up the slicer to display the date the user wants to select, but to filter by the "offset" date.
I don't understand your questions about using a card to display results... if the measure returns a count you can display it on a card.
Help when you know. Ask when you don't!
Sorry, I am quite new in DAX so I may not be clear in my question, I am gonna try to explain it in a understandable way:
1- As shown in the following date, that's my excel, so my idea is to sum all the numbers of a certaing indicator and date. So one if a want to see X1 indicator, show me the total number (sum 1+1+1 = 3). With dates row I changed it to unpivot table to make an slicer (so if I choose one date in the slicer it filters the measures created).
Week | ||||
Indicator | 16-03-20 | 23-03-20 | 30-03-20 | 06-04-20 |
X1 | 1 | 1 | 1 | |
X2 | 2 | 5 | ||
X3 | 1 |
2- I created many measures to carry out my idea:
Hi,
You should have a Calendar Table with a relationship from the Attribute column of XXX table to the Date column of the Calendar Table. Your slicer should be build from the Date column of the Calendar Table. Write this measure
=CALCULATE([Mails],DATESBETWEEN(Calendar[Date],MIN(Calendar[Date])-7,MIN(Calendar[Date])-7))
Hope this helps.
// It's actually very easy to do what you want
// but only on condition your model is built
// correctly. Calendar table must be THE
// date table in the model connected to your
// fact table. The days that belong to one
// week should have a column next to them with the date
// of the first day of the week. This should be
// named something like [Week Start]. These week starts
// should be in your slicer as well.
[Mails PW] = // mails previous week
var __oneWeekVisible = HASONEVALUE( 'Calendar'[Week Start] )
var __dayLag = 7 // back one week
var __result =
CALCULATE(
[Mails],
DATEADD(
'Calendar'[Date],
-__dayLag,
DAY
)
)
return
if( __oneWeekVisible, __result )
Best
D
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 |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |