Forum Discussion
SelectedValue Measure DAX not working
- 4 years ago
Hi Anonymous ,
According to your description, I create a sample.
The two tables have relationship.
Columns cannot be directly quoted in measure, as measure is aggregation operation, it can only refer to unique values, not a column. You can add MAX function to return the value of the current row, like this:
BrandName SelectedFormula = var SelectedValue = SELECTEDVALUE(store[cdk_accounting_account]) RETURN SWITCH(TRUE(), SelectedValue = "PNH-A", IF(MAX(inventoryvehicle_v[Brand Name]) = "Porsche", MAX(inventoryvehicle_v[Brand Name]), "Others"), SelectedValue = "LH-A", IF(MAX(inventoryvehicle_v[Brand Name]) IN{ "LAMB" ,"LAM" ,"MCLA" ,"MCLRN"}, MAX(inventoryvehicle_v[Brand Name]), "Others"))In this way, the measure works, but the brand name cann't be filtered by slicer.
You can modify the formula like this:
BrandName SelectedFormula 2 = VAR SelectedValue = SELECTEDVALUE ( store[cdk_accounting_account] ) RETURN SWITCH ( TRUE (), SelectedValue = "PNH-A", IF ( MAX ( 'inventoryvehicle_v'[account] ) = "PNH-A", IF ( MAX ( inventoryvehicle_v[Brand Name] ) = "Porsche", MAX ( inventoryvehicle_v[Brand Name] ), "Others" ), BLANK () ), SelectedValue = "LH-A", IF ( MAX ( 'inventoryvehicle_v'[account] ) = "LH-A", IF ( MAX ( inventoryvehicle_v[Brand Name] ) IN { "LAMB", "LAM", "MCLA", "MCLRN" }, MAX ( inventoryvehicle_v[Brand Name] ), "Others" ), BLANK () ) )Here's the result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
According to your description, I create a sample.
The two tables have relationship.
Columns cannot be directly quoted in measure, as measure is aggregation operation, it can only refer to unique values, not a column. You can add MAX function to return the value of the current row, like this:
BrandName SelectedFormula =
var SelectedValue = SELECTEDVALUE(store[cdk_accounting_account])
RETURN
SWITCH(TRUE(),
SelectedValue = "PNH-A", IF(MAX(inventoryvehicle_v[Brand Name]) = "Porsche", MAX(inventoryvehicle_v[Brand Name]), "Others"),
SelectedValue = "LH-A", IF(MAX(inventoryvehicle_v[Brand Name]) IN{ "LAMB" ,"LAM" ,"MCLA" ,"MCLRN"}, MAX(inventoryvehicle_v[Brand Name]), "Others"))
In this way, the measure works, but the brand name cann't be filtered by slicer.
You can modify the formula like this:
BrandName SelectedFormula 2 =
VAR SelectedValue =
SELECTEDVALUE ( store[cdk_accounting_account] )
RETURN
SWITCH (
TRUE (),
SelectedValue = "PNH-A",
IF (
MAX ( 'inventoryvehicle_v'[account] ) = "PNH-A",
IF (
MAX ( inventoryvehicle_v[Brand Name] ) = "Porsche",
MAX ( inventoryvehicle_v[Brand Name] ),
"Others"
),
BLANK ()
),
SelectedValue = "LH-A",
IF (
MAX ( 'inventoryvehicle_v'[account] ) = "LH-A",
IF (
MAX ( inventoryvehicle_v[Brand Name] ) IN { "LAMB", "LAM", "MCLA", "MCLRN" },
MAX ( inventoryvehicle_v[Brand Name] ),
"Others"
),
BLANK ()
)
)
Here's the result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for inputs and the example file! This resolved my issue.