Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I am using a SWITCH function to select between cases and revenue as a measure. For cases, the format should be a whole number. For revenue, the format should be currency. This is my formula:
Measure Selection = IF(ISCROSSFILTERED('Measure'[Measure]),
SWITCH(
TRUE(),
VALUES('Measure'[Measure]) = "Gross Revenue", FORMAT([Total Sales], "Currency"),
VALUES('Measure'[Measure]) = "Cases", FORMAT([Total Quantity], "0"),
BLANK()), BLANK())
where [Total Sales] = CALCULATE(SUM([Sales])) and [Total Quantity] = CALCULATE(SUM([Cases]))
Here is my 'Measure' table:
When I use FORMAT, my table shows blank values:
When I don't use the FORMAT function, my values do not naturally format the way I would like them to:
There are two possible solutions:
1. Find a way to get rid of the blank rows
2. Use a function other than FORMAT to format my values into whole numbers and currency.
Here's some sample data:
Product | Sales | Cases |
E.Com - Cakes & Pies/Shells | 10 | 1 |
E.Com - Cakes & Pies/Shells | 30 | 3 |
Pound Cake | 4000 | 1000 |
Pound Cake | 1472 | 368 |
Thanks!
Solved! Go to Solution.
In your SWITCH statement you need to also check that there is actually a value, or FORMAT will happily produce an empty string.
Measure Selection = IF(ISCROSSFILTERED('Measure'[Measure]),
SWITCH(
TRUE(),
VALUES('Measure'[Measure]) = "Gross Revenue" && [Total Sales]<>0, FORMAT([Total Sales], "Currency"),
VALUES('Measure'[Measure]) = "Cases" && [Total Quantity]>0, FORMAT([Total Quantity], "0"),
BLANK()), BLANK())
@ratgdillon , I think you have to use max here
Measure Selection = IF(ISCROSSFILTERED('Measure'[Measure]),
SWITCH(
TRUE(),
Max('Measure'[Measure]) = "Gross Revenue", FORMAT([Total Sales], "Currency"),
max('Measure'[Measure]) = "Cases", FORMAT([Total Quantity], "0"),
BLANK()), BLANK())
But this will make date type as text .
This example can also help you how to handle measure Slicer -https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slic...
I have Stacked Chart, but can't get this working. do you have any other solution?
In your SWITCH statement you need to also check that there is actually a value, or FORMAT will happily produce an empty string.
Measure Selection = IF(ISCROSSFILTERED('Measure'[Measure]),
SWITCH(
TRUE(),
VALUES('Measure'[Measure]) = "Gross Revenue" && [Total Sales]<>0, FORMAT([Total Sales], "Currency"),
VALUES('Measure'[Measure]) = "Cases" && [Total Quantity]>0, FORMAT([Total Quantity], "0"),
BLANK()), BLANK())
Hello, I'm looking a measure that change the format the format of salesAmount dynamically based on currency selection slicer and you give me this code : Sales Amount Selected Currency = VAR SelectedCurrency = SELECTEDVALUE('SlicerTable'[Currency]) RETURN IF(SelectedCurrency = "Local", SUM('SalesTable'[SalesAmount]), IF(SelectedCurrency = "Euro", FORMAT(SUM('SalesTable'[SalesAmount_EUR]), "€#,##0.00"), IF(SelectedCurrency = "Dollar", FORMAT(SUM('SalesTable'[SalesAmount_EUR]), "$#,##0.00") ) ) ) the problem when i use this measure, it show me a blank values out of the range sales dates (my sales dates years 2022 and 2023 before using the measure , after using the measure i found year 2014 and 2015 with blank values). how we can solve the problem ?
Why this is not working for stacked Chart?
Hi,
I added "ISCROSSFILTERED" and checking actually a value exists in my switch funtion but format option didn't work out.
My final measure is dependant on multiple measures.
Are there any steps needs to be taken.
Thank you in advance.
User | Count |
---|---|
54 | |
22 | |
19 | |
16 | |
11 |
User | Count |
---|---|
81 | |
55 | |
39 | |
20 | |
12 |