Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

Measure as filter

Hi Guys.

 

I have a formula that works correctly, but if you did not select any filter, mark  an error, how can I do it so that if I do not have anything selected, show me the 3 values.

 

Measure Selection =
SWITCH( TRUE();
VALUES('Measure Dimensions'[Measure]) = "Total Sales"; [Total Sales];
VALUES('Measure Dimensions'[Measure]) = "Total Costs"; [Total Costs];
VALUES('Measure Dimensions'[Measure]) = "Total Profits"; [Total Profits];
BLANK())

 

Thx for all your help.

The force is be with u..all values.PNG

2 ACCEPTED SOLUTIONS
Nishantjain
Continued Contributor
Continued Contributor

@Anonymous, I don't think this is possible by using a Switch function. Switch will always return 1 measure.

 

I would suggest you try the following:

 

Step 1: Add all 3 measures in your bar chart. Make sure that your measure uses both "Calculate" and "Filter" function 

e.g. CALCULATE(SUM(VALUES),FILTER(TABLE, TABLE[ACCOUNT] = "TOTAL SALES"

 

Step 2: Create a slicer for your accounts i.e. "Total Sales", "Total costs" and "Total Profit". 

 

Now when you select nothing in the slicer, all the measures should be visible. If you select any one value, only that measure is shown. 

 

Hope this help

Nishant

View solution in original post

Anonymous
Not applicable

Create a Selection Table that contains 2 fields.  A numeric ID column and a String Text column.  Create a slicer that will display the values in your Selection Table.  When any of these selections are chose, the context of Power BI will filter down to just that single row.

 

Now if you do a MIN('Selection Table'[ID]) you will know the value of your selection.  If nothing is selected you will get the smallest value in your selection table, which you could make as "(Blank)"

 

From here, you could use that within a Switch statement to run different measures depending on the Values in you selection table.  So 0 could equal "Error Message", 1 could be your first measure, 2 could be your second measure and so forth.

View solution in original post

7 REPLIES 7
v-yuezhe-msft
Employee
Employee

@Anonymous,

I don't think you can achieve your requirement in this scenario. When you choose nothing in the slicer, only one measure or a single value can be shown.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Create a Selection Table that contains 2 fields.  A numeric ID column and a String Text column.  Create a slicer that will display the values in your Selection Table.  When any of these selections are chose, the context of Power BI will filter down to just that single row.

 

Now if you do a MIN('Selection Table'[ID]) you will know the value of your selection.  If nothing is selected you will get the smallest value in your selection table, which you could make as "(Blank)"

 

From here, you could use that within a Switch statement to run different measures depending on the Values in you selection table.  So 0 could equal "Error Message", 1 could be your first measure, 2 could be your second measure and so forth.

Nishantjain
Continued Contributor
Continued Contributor

@Anonymous, I don't think this is possible by using a Switch function. Switch will always return 1 measure.

 

I would suggest you try the following:

 

Step 1: Add all 3 measures in your bar chart. Make sure that your measure uses both "Calculate" and "Filter" function 

e.g. CALCULATE(SUM(VALUES),FILTER(TABLE, TABLE[ACCOUNT] = "TOTAL SALES"

 

Step 2: Create a slicer for your accounts i.e. "Total Sales", "Total costs" and "Total Profit". 

 

Now when you select nothing in the slicer, all the measures should be visible. If you select any one value, only that measure is shown. 

 

Hope this help

Nishant

Anonymous
Not applicable

Hi,

 

I have a question that is kinda related:

Is it possible to have two different measure formats within the same filter that has two measures? Whole Number and percentage.

 

Thanks in advance,

Best regards,

Milos

Anonymous
Not applicable

Yes and no.

 

The no portion of my answer is that the data format is specified on the measure itself.  The switching measure itself will need a data format.  If you select percentage, both will be percentage.  If you select whole number, both will be whole number.

 

The yes portion of my answer is that you might be able to circumvent the problem by making the measure "Text" and using a format function around each measure to force the result to display in the specific format you want.  Even though it will be text, in most cases you will likely get the result you desire.  There will be some scenarios where making it text could be a problem, but thats just something to consider.

Anonymous
Not applicable

@Nishantjain, Thank you very much for your help, the truth is new in powerbi and I do not understand your approach very well, you could support me with an example please. Thank you.

Anonymous
Not applicable

@AnonymousI don' think you can do that, why, because you're creating ONE measure and the measure shows the value for the one selected on the slicer, but i will be interesting if you can aproach the solution for this

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.