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
zainqazi96
Regular Visitor

DAX query for alternative of what if parameters

Hi Guys!

I'm encountering an problem in which i want to acheive what if parameters functionality because i'm using Report server and it won't work on RS , i need to use same working like pattern , now if i want to get all the values of a column in a measure how can i do it just like SQL query in which e.g select col1 from tab1; i want to achieve same thing in dax

1 ACCEPTED SOLUTION
v-kongfanf-msft
Community Support
Community Support

Hi @zainqazi96 ,

 

You can use reference in the power query first and then convert the table by unpivot column and remove the unwanted columns.

vkongfanfmsft_1-1708672318548.png

vkongfanfmsft_0-1708672269192.png

then create below formula in powerbi, enabling dynamic selection of column name in the slicer.

slicer_by_columnName = VALUES('Table (2)'[Attribute])

vkongfanfmsft_2-1708672364325.png

 

Best Regards,
Adamk Kong

 

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

3 REPLIES 3
v-kongfanf-msft
Community Support
Community Support

Hi @zainqazi96 ,

 

You can use reference in the power query first and then convert the table by unpivot column and remove the unwanted columns.

vkongfanfmsft_1-1708672318548.png

vkongfanfmsft_0-1708672269192.png

then create below formula in powerbi, enabling dynamic selection of column name in the slicer.

slicer_by_columnName = VALUES('Table (2)'[Attribute])

vkongfanfmsft_2-1708672364325.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Sahir_Maharaj
Super User
Super User

Hello @zainqazi96,

 

Can you please try the following:

 

1. Create a Calculated Table

DistinctColumnValues = DISTINCT('TableName'[ColumnName])

 

2. Use the calculated table to create a slicer in your report

 

3. Create a Measure to Reflect the "What If" Selection

DynamicMeasure = 
VAR SelectedValue = SELECTEDVALUE('DistinctColumnValues'[ColumnName], "Default Value")
RETURN
CALCULATE(
    [YourCalculation],
    FILTER(
        'TableName',
        'TableName'[ColumnName] = SelectedValue
    )
)

 

Hope this helps!


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

@Sahir_Maharaj i don't get it , how can i use column name in slicers , based on dynamic selections

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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