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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Create a Measure from Field Parameters

I'm new to field parameters and am trying to see if this is possible. I have two field parameter lists that are simply listing various explicit measures I've created to provide counts of values from different columns in my table.

Numerator = {
    ("Count of A", NAMEOF('Table'[Count of A]), 0),
    ("Count of B", NAMEOF('Table'[Count of B]), 1),
    ("Count of C", NAMEOF('Table'[Count of C]), 2)
}
 
Denominator = {
    ("Count of A", NAMEOF('Table'[Count of A]), 0),
    ("Count of B", NAMEOF('Table'[Count of B]), 1),
    ("Count of C", NAMEOF('Table'[Count of C]), 2)
}
 
I want to create a new measure that calculates the division of the selected numerator by the selected denominator. This didn't work:
Measure = CALCULATE(
                DIVIDE(
                        SELECTEDVALUE(Numerator[Numerator]),
                        SELECTEDVALUE(Denominator[Denominator])
                        )
                    )
Is what I'm trying to do possible?
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous I don't think this is going to work, in your measure you need to check which option is selected and then use the switch/if function to use the respective measure based on the selected value. check this post on how to get the selected value Using SELECTEDVALUE with Fields Parameters in Power BI - SQLBI

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



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.

View solution in original post

3 REPLIES 3
Zihang98
Regular Visitor

I met very similar problem with you. What I did at the end is:

 

Under each field parameters, you have three columns, Name, Fields, Order. We can't use the Name and Fields in the if function becasue the PowerBI will tell us it's a composition key. But we can use order column.

 

Under Order column, each number represents one measure we have in our table. So for example, I will write as:

 

= If (Numeator'[Order] = 0, Table'[Count of A], if (Numeator'[Order] = 1, Table'[Count of B],Table'[Count of C])) / If (Denominator'[Order] = 0, Table'[Count of A], if (Denominator'[Order] = 1, Table'[Count of B],Table'[Count of C]))

 

Hope it helps.

speedramps
Super User
Super User

We want to help you but your description is too vaugue.

Please write it again clearly.

Provide example input data as table text (not a screen print) so we can import the data to build a soution for you.

Also provide the example desired output, with a clear description of the process flow.

Take care to use the same table and field names in the input, output and description so we can understand your problem and help you.

Dont bother posting your DAX code that does not work or suggesting things like "Field parameters". 

Just describe the input, the outputs and the flow and let us decide the best DAX method. Thanks.

 

You will get a quick response if you put time and effort into writing clear problem descriptions.

Vaugue descriptions waste your time and ourtime.

Look foward to helping you when the above information is forthcoming.

 

 

 

 

parry2k
Super User
Super User

@Anonymous I don't think this is going to work, in your measure you need to check which option is selected and then use the switch/if function to use the respective measure based on the selected value. check this post on how to get the selected value Using SELECTEDVALUE with Fields Parameters in Power BI - SQLBI

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.