Forum Discussion
User Input is not recognized in DAX formula
Hi Anonymous ,
Try to test the below:
Step1,create silcer table for per:
Then use the below:
test1 = SWITCH ( TRUE (),
(SELECTEDVALUE('Table'[source])= "VW1"&& SELECTEDVALUE('Table'[PER])<= SELECTEDVALUE(preslicer[preslicer])), [measure1],
( SELECTEDVALUE('Table'[Source])= "VW2"&&SELECTEDVALUE('Table'[PER]) = SELECTEDVALUE(preslicer[preslicer])) , [Measure2] , 0 )
return:(return value according measure1 ,and measure)
You could download my pbix file if you need.
Did I answer your question? Mark my post as a solution!
Best Regards
Lucien
Hi Lucien,
Thank you for trying to help. I downloaded your pbix and after some exploring, I made a few changes just to clarify what I am trying to do. If we'd just focus on VW1 and VW2 in the sample data that you created and for which formula you created, we would expect the following values for the test1 measure. And for the sake of simplicity, we will delete the Source and Per slicers so we will be left with just the preslicer and the table.
To make it simple, I have captured your test data for VW1 and VW2 here to make it easy to follow:
| Source | PER | Value |
| VW1 | 1 | 3 |
| VW1 | 2 | 64 |
| VW1 | 2 | 1 |
| VW2 | 2 | 3 |
| VW2 | 3 | 21 |
| VW2 | 4 | 31 |
| VW2 | 5 | 3 |
If we select 1 in the preslicer, we want to add up all the values for periods less than or equal to 1 for VW1 and for VW2, only values equal to period 1. So VW1 should have 3 because there is only one record for VW1 and period 1 and that value is 3. VW2 should have 0 because there is no record for period 1. In other words, selecting 1 in the preslicer should result in VW1 = 3 and VW2 = 0.
If we select 2 in the preslicer, meaning periods 1 + period 2 for VW1, VW1 should be (3+ 64 + 1) = 68. VW2 value for period 2 should be just 3.
If we select 3 in the preslicer, we have periods 1 + period 2 but no period 3 for VW1 so VW1 should still be (3+ 64 + 1) = 68, VW2 should be 21, which is for period 3 only.
Likewise, if we select 4 in the preslicer, we want period 1 -> 4 for VW1, which is still 68 and for VW2, period 4, it is 31.
Selecting 5 in the preslicer, we want period 1 ->5 for VW1, which is still 68 and for VW2, period 5, it is 3.
This is the measure formula that I was trying to work with
Report_Amount = SWITCH(TRUE(),
AND([SOURCE] = "VW1", [PER] <= xxx), [AMOUNT],
AND([SOURCE] = "VW2", [PER] = xxx), [AMOUNT], 0)
where xxx is the preslicer value that the user would select. But so far all my attempts to make the formula to look at this preslicer value failed.
Thank you so much for your interest.
Daniel