Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ahuhn
Helper I
Helper I

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

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.

View solution in original post

8 REPLIES 8
v-cherch-msft
Employee
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"
    )
)

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.

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

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.
ahuhn
Helper I
Helper I

I forgot to add screenshot:

 

Picture1.png

@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

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

luxpbi
Helper V
Helper V

Hi,

 

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

 

Thank you

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

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



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.