Quantcast
Channel: Desktop topics
Viewing all articles
Browse latest Browse all 217511

If Statement in DAX

$
0
0

Hi,

 

  I am generating  a custom filter based on my column values Sales and Units. So for this I am using IF statement to select between Sales and Units. Now it is working fine if the user selects either Sales or Units to filter but I am not getting any value if the user does not selects any of the 2. What I want is that the graph should display data for both Sales and Units if the user selects nothing in the filter. Below is the code and dummy table:

 

DisplayValue =
IF( HASONEVALUE ( DisplayBy[DisplayBy] ),  IF( VALUES( DisplayBy[DisplayBy] ) = "Sales",  SUM( Table1[total Sales] ),  SUM (Table1[Total Units] )
  ),
  "Please select only one measure to display from the slicer"
)

small.png

So instead of "Please select only one measure to display from the slicer"  I need to display data for both Sales and Units based on years.

 

Also I can not unpivot the data as the tables are dynamic tables that are generated on different logics. So combining them and then using is not an option.

 

Thanks in advance.


Viewing all articles
Browse latest Browse all 217511

Trending Articles