The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have a report with 4 pages that are built from 3 interconnected tables (shown below).
I want my report (both desktop and online) to have a default value of Ph = 1 AND Ph = 2 across all pages when no PH values are selected . However when a user selects a Ph value it changes to that value.
I have multiple visuals and matrixes across the four pages so it would be a bit tedious to create a single measure for each page. Please help!
Solved! Go to Solution.
Hi @FkZ0
Thank you for reaching out microsoft fabric community forum.
Yes, you can definitely set default values for both Ph and dates in the same measure.
The idea is to check if the user has made a selection for either one. If not, you can apply your own default values—like Ph = 1 or 2, and a specific date range. Here's an example of how you can do it:
DefaultPhDateMeasure =
IF (
ISFILTERED('Table1'[Ph]) && ISFILTERED('DateTable'[Date]),
-- If the user has selected both Ph and Date, just show the actual values
SUM('Table1'[Values]),
CALCULATE (
SUM('Table1'[Values]),
-- Apply default Ph filter if nothing is selected
IF (
NOT ISFILTERED('Table1'[Ph]),
'Table1'[Ph] IN {1, 2},
TRUE()
),
-- Apply default Date filter if nothing is selected
IF (
NOT ISFILTERED('DateTable'[Date]),
'DateTable'[Date] >= DATE(2024, 1, 1) && 'DateTable'[Date] <= DATE(2024, 12, 31),
TRUE()
)
)
)
Just swap in your actual table and column names, and update the date range to whatever default you'd like. This measure will automatically apply defaults when nothing is selected, but still respect user selections when they do choose a Ph or date.
If this solution helps, please consider giving us Kudos and accepting it as the solution so that it may assist other members in the community
Thank you.
Hi @FkZ0
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.
Hi @FkZ0
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
Hi @FkZ0
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hi @FkZ0
Thank you for reaching out microsoft fabric community forum.
Yes, you can definitely set default values for both Ph and dates in the same measure.
The idea is to check if the user has made a selection for either one. If not, you can apply your own default values—like Ph = 1 or 2, and a specific date range. Here's an example of how you can do it:
DefaultPhDateMeasure =
IF (
ISFILTERED('Table1'[Ph]) && ISFILTERED('DateTable'[Date]),
-- If the user has selected both Ph and Date, just show the actual values
SUM('Table1'[Values]),
CALCULATE (
SUM('Table1'[Values]),
-- Apply default Ph filter if nothing is selected
IF (
NOT ISFILTERED('Table1'[Ph]),
'Table1'[Ph] IN {1, 2},
TRUE()
),
-- Apply default Date filter if nothing is selected
IF (
NOT ISFILTERED('DateTable'[Date]),
'DateTable'[Date] >= DATE(2024, 1, 1) && 'DateTable'[Date] <= DATE(2024, 12, 31),
TRUE()
)
)
)
Just swap in your actual table and column names, and update the date range to whatever default you'd like. This measure will automatically apply defaults when nothing is selected, but still respect user selections when they do choose a Ph or date.
If this solution helps, please consider giving us Kudos and accepting it as the solution so that it may assist other members in the community
Thank you.
@FkZ0 Create a measure that will check if any Ph value is selected. If no Ph value is selected, it will return the sum of values for Ph 1 and 2. If a Ph value is selected, it will return the sum for the selected Ph value.
DAX
DefaultPhValues =
IF(
ISFILTERED('Table1'[Ph]),
SUM('Table1'[Values]),
CALCULATE(
SUM('Table1'[Values]),
'Table1'[Ph] IN {1, 2}
)
)
Use this measure in your visuals instead of directly using the Values column. This way, the measure will handle the default filtering logic.
To ensure the default filter is applied across all pages, you can set a report-level filter for Ph values 1 and 2. Here’s how you can do it:
Go to the Filters pane in Power BI Desktop.
Drag the Ph field to the "Report level filters" section.
Set the filter to include only Ph values 1 and 2.
Publish the report to Power BI Service.
Verify that the default filter (Ph = 1 and Ph = 2) is applied when no Ph value is selected.
Check that selecting a different Ph value updates the visuals accordingly.
Proud to be a Super User! |
|
I have a follow up question, I've got another measure that does the same thing but with regards to dates from date tables, can my function have two default conditions? How would I do this?