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
YASHASHRI
Helper I
Helper I

DAX TO GET TWO OPTION SO THAT I CAN FILTER

YASHASHRI_0-1684748369309.png

Hi Community,
I am facing a problem in creating a dax formula.
so i have one column with stages. With that column i want to create another column where i will get 2 option. 
Option 1 is "Total"
Option 2 is "Stage 2"

total is basically adding of all stages whereas second stage is only stage 2.

Can it be possible with DAX? if yes please help me with the dax or give another solution.

Thanks,
Yashashri

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

Hi @YASHASHRI ,

 

You could create a table with "TOTAL" and "STAGE 2" by entering data.

vstephenmsft_0-1685070665420.png

Then use the SWITCH function to filter.

Measure = SWITCH(SELECTEDVALUE('Table (2)'[SLICER]),"TOTAL",SUMX(ALL('Table'),[STAGES]),"STAGE 2","STAGE 2")

vstephenmsft_1-1685070784383.png

vstephenmsft_2-1685070790548.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

5 REPLIES 5
v-stephen-msft
Community Support
Community Support

Hi @YASHASHRI ,

 

You could create a table with "TOTAL" and "STAGE 2" by entering data.

vstephenmsft_0-1685070665420.png

Then use the SWITCH function to filter.

Measure = SWITCH(SELECTEDVALUE('Table (2)'[SLICER]),"TOTAL",SUMX(ALL('Table'),[STAGES]),"STAGE 2","STAGE 2")

vstephenmsft_1-1685070784383.png

vstephenmsft_2-1685070790548.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

Mrxiang
Helper II
Helper II

The sum of all stages is:
Total = CALCULATE(SUM(Table1[Stage]), Table1[Stage])
To get the sum of only Stage 2, you can use the IF statement:
Total = CALCULATE(SUM(Table1[Stage]), IF(Table1[Stage] = "Stage 2", 1, 0))
YASHASHRI
Helper I
Helper I

Not giving me the result. 

@YASHASHRI 
Can you please provide a screenshot of the results and include the dax code that you have used?

tamerj1
Super User
Super User

Hi @YASHASHRI 
Slicer table is a disconnected table inserted manually that has two values ("TOTAL", "STAGE @2")
Then to sum a column for example you can use the following DAX

Value =
IF (
    SELECTEDVALUE ( SlicerTable[Option] ) = "STAGE2",
    CALCULATE ( SUM ( 'Table'[Column] ), 'Table'[Stage] = 2 ),
    SUM ( 'Table'[Column] )
)

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.

Top Solution Authors