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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Need Help with DAX Measure

Hi Power BI Community,

 

I need help in Writing a DAX measure.

 

I have 2 measures A, B and a Slicer Column C.

 

If No Value or All or selected from Slicer, it should take value from Measure A else from Measure B.

 

Thanks in advance.

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

Hi, @Anonymous 

 

You can try:

measure =
SWITCH (
    TRUE (),
    DISTINCT ( Input[Customer] ) = BLANK ()
        || DISTINCT ( Input[Customer] ) = DISTINCT ( ALL ( Input[Customer] ) ), SUM ( Input[Customer Mix] ),
    [Fx Customer Mix]
)

Best Regards

Janey Guo

 

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

7 REPLIES 7
v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

You can try:

measure =
SWITCH (
    TRUE (),
    DISTINCT ( Input[Customer] ) = BLANK ()
        || DISTINCT ( Input[Customer] ) = DISTINCT ( ALL ( Input[Customer] ) ), SUM ( Input[Customer Mix] ),
    [Fx Customer Mix]
)

Best Regards

Janey Guo

 

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

gabrielreversi
Frequent Visitor

Hi @Anonymous 

what do you look for would be that way?

 
gabrielreversi_0-1623254361236.png 
gabrielreversi_1-1623254397835.png
gabrielreversi_2-1623254427124.png

 

 

 

Anonymous
Not applicable

Capture.PNG

 

Hi Power BI Community,

 

If All Values or No Values are selected from Customer Slicer, the above table should use Customer Mix Column, else it should use Fx Customer Mix Column.

 

Please help, thanks in advance.

 

Thank you

Kuber Kumar

Hi @Anonymous 

 

You use next measure:

 

measure = 

SWITCH(TRUE,

ISFILTERED(table[customer]), [Fx Customer Mix], [Customer Mix])

Anonymous
Not applicable

@gabrielreversi Thank you for the quick response, I tried the measure, it is not giving the expcected result.

 

Please find both the images below

 

KadaKuberKumar_0-1623328688077.png

Capture.PNG

You will need dimension table dCustomer and build the measure using that dimension table.

 

This time using HASONVALUE.

 

gabrielreversi_0-1623330038770.png

 

 

gabrielreversi_1-1623330075940.png

 

gabrielreversi_2-1623330090790.png

 

 

 

 

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Try this measure:

_variableOutput =
IF(
  HASONEVALUE(slicer[column C]),
  [measure B],
  [measure A]
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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