Forum Discussion
Need help with parameter comparison in Power BI
- 2 years ago
Hi, apai1990
I have the following data table:
I have the following two parameters:
I created a metric using the following DAX expression:
IsInPeriod = VAR pyS = SELECTEDVALUE('Start year'[Start year]) VAR pyE = SELECTEDVALUE('End Year'[End Year]) VAR ppS = SELECTEDVALUE(SalaryPeriods[SalaryPeriod]) VAR pp = SELECTEDVALUE(Payments[Payment Period]) VAR py = SELECTEDVALUE(Payments[Payment Year]) RETURN IF ( NOT ISBLANK(pyS) && NOT ISBLANK(pyE) && NOT ISBLANK(ppS), IF ( pyS = pyE, IF (py = pyS && pp = ppS, "In Period", "Not In Period"), IF (py = pyS || py = pyE || (py > pyS && py < pyE) && pp >= ppS, "In Period", "Not In Period") ), "Parameters Not Set" )Use the following fields in the table vision object:
The results are as follows:
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
apai1990 i am struggling to understand the output of the logic.
Dax output is single value, 1 condition.
Example:
If you start like this:
now you should write expected output, example: Periods[Start Year] and name of this new column will be "Payment Year".
In your statement above, instead of 1 output you wrote:
then [Payment year] = [Start Year] AND [Payment period]= [Salary Period]
ELSEIF
As these are 2 outputs, the logic is not understandable to dax.
The easiest would be to share screenshot of data and expected output, then it will be clear what to do.
Cheers,
Nemanja Andic