Forum Discussion
use parameters in dax
I made a DAX measure:
Measure = CALCULATE(COUNT(Sheet1[Status]),FILTER(Sheet1,[MonthUpdated]="201810" && [Status]="Alpha"))
I also created a parameter YYYYMM to represent [MonthUpdated], to permit the user to choose month of interest for Alpha projects.
Measure = CALCULATE(COUNT(Sheet1[Status]),FILTER(Sheet1,[MonthUpdated]=YYYYMM && [Status]="Alpha"))
2 issues:
1 - When I make a slicer for the parameter, only one option exists (ie 201809 or 201810, or whatever I set the default value on), and none of the other options are available
2 - When I reference the parameter in the DAX equation, the calculation is incorrect
Any suggestions?
Hi ahuhn
You can get the other count which is not selected by slicer with below measure.
Measure =
CALCULATE (
MAX ( Sheet1[MonthUpdated] ),
FILTER (
Sheet1,
Sheet1[MonthUpdated] <> SELECTEDVALUE ( Slicer[YYYYMM] )
&& Sheet1[Status] = "Alpha"
)
)
Regards,
Cherie
8 Replies
- v-cherch-msft
Microsoft Employee
Hi ahuhn
You may create a slicer table as below. Then create a measure with SELECTEDVALUE Function to get the value as requested.
Count = CALCULATE ( COUNT ( Sheet1[Status] ), FILTER ( Sheet1, Sheet1[MonthUpdated] = SELECTEDVALUE ( Slicer[YYYYMM] ) && Sheet1[Status] = "Alpha" ) )Regards,
Cherie
- ahuhn
Advocate I
Anonymous that is great, I love it!
Just a follow up.
I want to be able to subtract another month's value, also being chosen by the user. I tried your method, but after selecting the slicer to 201809, the second slicer is also subsetted, and thus has only one option.
This is the reason I was trying to use parameters
Any suggestions? Can you answer here, or shall I create a new thread?
- v-cherch-msft
Microsoft Employee
Hi ahuhn
You can get the other count which is not selected by slicer with below measure.
Measure =
CALCULATE (
MAX ( Sheet1[MonthUpdated] ),
FILTER (
Sheet1,
Sheet1[MonthUpdated] <> SELECTEDVALUE ( Slicer[YYYYMM] )
&& Sheet1[Status] = "Alpha"
)
)
Regards,
Cherie
- luxpbi
Helper V
Hi,
Can you share sample dumy data and tell what are the results expected.
Thank you
- ahuhn
Advocate I
Status MonthUpdated Alpha 201810 Alpha 201810 Beta 201810 Gamma 201810 Gamma 201810 Alpha 201809 When user selects parameter 201810, alpha result should be 2
when user seelcts 201809, alpha result should be 1
Unforunately, the parameters cannot be altered either
- ahuhn
Advocate I
I forgot to add screenshot:
- parry2k
Super User
ahuhn it is not clear what you are trying to do? Are you setting value for parameters? Why you are setting it as a slicer? Could you provide more details.
Please look at this link on how to get your answer quickly
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490