Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a dim_date table with:
- date
- week number
I also have measures: 'Yesterday' and 'Last full week number'
Dim date joins to my transactional data on dim.date[date] = transactional.[event date]
I have a parameter which pick date granularity either daily or weekly.
How can I achieve the following logic:
IF parameter = daily -> show data to yesterday
ID parameter = weekly -> show data till last full week
I am not sure if it is best to do it somehwere in visualisation, or build into a measure?
The graph is pretty simple, I just want 'This week'to disappear if parameter is set to weekly, but for daily show all data till yesterday
Solved! Go to Solution.
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
expected result measure: =
VAR _selectedperiod =
SELECTEDVALUE ( parameter_period[parameter_period Order] )
VAR _yesterday =
TODAY () - 1
VAR _lastweek =
MAXX (
FILTER (
ALL ( calendar_dim[End of Week] ),
calendar_dim[End of Week] < TODAY ()
),
calendar_dim[End of Week]
)
RETURN
SWITCH (
TRUE (),
_selectedperiod = 0,
CALCULATE (
SUM ( transaction_fact[quantity] ),
KEEPFILTERS ( calendar_dim[date] <= _yesterday )
),
_selectedperiod = 1,
CALCULATE (
SUM ( transaction_fact[quantity] ),
KEEPFILTERS ( calendar_dim[End of Week] <= _lastweek )
)
)
HI @maziiw,
Thankyou @Jihwan_Kim and @danextian for your reply on the issue.
I'm glad to hear that your query was resolved! If the response provided by the community member addressed your concern, kindly confirm.
Marking it as Accept Answer and give us Kudos if you found it helpful allows us to ensure that the solutions shared are valuable for the entire community.
If you have any further questions, feel free to reach out!
Thank you for your cooperation!
Hi @maziiw
There are several approaches you can follow:
You can create a measure referencing a disconnected table
PresetValue =
VAR _LatestDate =
CALCULATE ( MAX ( SampleData[Date] ), REMOVEFILTERS ( SampleData ) ) -- or TODAY()-1
VAR _Yesterday =
CALCULATE (
[Sum of Value],
KEEPFILTERS ( Dates[Date] = _LatestDate )
)
VAR _LastFullWeek =
CALCULATE (
[Sum of Value],
KEEPFILTERS ( Dates[Date] >= _LatestDate - 6 && Dates[Date] <= _LatestDate )
)
RETURN
SWITCH (
SELECTEDVALUE ( Presets[DatesPreset] ),
"Yesterday", _Yesterday,
"Last Full Week", _LastFullWeek,
[Sum of Value]
)
You can convert this measure to a calculation group item so the same logic is applied to different measures
You can also create a date preset table that has the name of the preset and the dates included. https://youtu.be/A3XvBiNdjXI
Please see the attached sample pbix.
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
expected result measure: =
VAR _selectedperiod =
SELECTEDVALUE ( parameter_period[parameter_period Order] )
VAR _yesterday =
TODAY () - 1
VAR _lastweek =
MAXX (
FILTER (
ALL ( calendar_dim[End of Week] ),
calendar_dim[End of Week] < TODAY ()
),
calendar_dim[End of Week]
)
RETURN
SWITCH (
TRUE (),
_selectedperiod = 0,
CALCULATE (
SUM ( transaction_fact[quantity] ),
KEEPFILTERS ( calendar_dim[date] <= _yesterday )
),
_selectedperiod = 1,
CALCULATE (
SUM ( transaction_fact[quantity] ),
KEEPFILTERS ( calendar_dim[End of Week] <= _lastweek )
)
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
83 | |
67 | |
62 | |
46 | |
45 |