cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ahuhn Regular Visitor
Regular Visitor

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?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: use parameters in dax

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

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
8 REPLIES 8
luxpbi Member
Member

Re: use parameters in dax

Hi,

 

Can you share sample dumy data and tell what are the results expected.

 

Thank you

ahuhn Regular Visitor
Regular Visitor

Re: use parameters in dax

I forgot to add screenshot:

 

Picture1.png

Super User
Super User

Re: use parameters in dax

@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

 

 





Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Kudos Help Smiley Happy
Connect with me on Linkedin. Feel free to email me with any of your BI needs.




 




ahuhn Regular Visitor
Regular Visitor

Re: use parameters in dax

StatusMonthUpdated
Alpha201810
Alpha201810
Beta201810
Gamma201810
Gamma201810
Alpha201809

 

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

Super User
Super User

Re: use parameters in dax

@ahuhn so if I understood correctly, you have a parameter which user uses to enter the month value and then you want to show count of status based on month value entered by users in parameter, correct?





Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Kudos Help Smiley Happy
Connect with me on Linkedin. Feel free to email me with any of your BI needs.




 




Community Support Team
Community Support Team

Re: use parameters in dax

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"
    )
)

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ahuhn Regular Visitor
Regular Visitor

Re: use parameters in dax

@Cherie 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?

Highlighted
Community Support Team
Community Support Team

Re: use parameters in dax

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

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.