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
speedramps
Super User
Super User

How can Field Parameters be used in DAX measures?

Can a Field Parameter DAX expert help me please.

How can Field Parameters be used in DAX measures?

Click here to download example PBIX from Onedrive 

In the attached PBIX I have crated a fictional example for a pet shop
There is a Field Parameter for types (Vet, Pet type and Colour)

and Field Parameter for metrics (Cost, Sales, Profit and Tax)

The green card = the field parameter “Metrics[Metrics Value]”.

The Row count = the number of rows.

I want the bottom card to show the average but the DAX syntax won’t allow the Field Parameter highlighted in red

Average =
DIVIDE(
Metrics[Metrics Value],[Row count)

 

Please can you suggest a method of calculating the average of the Field Parameter without creating a separate formula for cost, sales, profit and tax. 


Please create an working example by downloading the above attached PBIX.

 

Thank you.

 

speedramps_0-1714146577107.png

 

 

 

 

 

2 REPLIES 2
DataInsights
Super User
Super User

@speedramps,

 

Try this measure:

 

Average = 
VAR vSelectedMetric =
    SWITCH (
        MAX ( Metrics[Metrics Value] ),
        "Costs", [Costs],
        "Sales", [Sales],
        "Profit", [Profit],
        "Tax", [Tax]
    )
VAR vResult =
    DIVIDE ( vSelectedMetric, [Row count] )
RETURN
    vResult

 

DataInsights_0-1714160314042.png

 





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

Proud to be a Super User!




Thank you very much for replying and going to the effort of writing a DAX script.

 

Your answer is a work arround.

 

However, it does not answer the question how to reference Field Paraneters in DAX measures.

 

Does anyone know the answer please?

 

 

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.