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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
BI_Power_Guy
Frequent Visitor

Equivalent of Break statement in DAX

Hi ,
I want to create a card visual that can show YTD,QTD,MTD  dynamically.I have 3 slicers for Year , Quarter and Date.I was thinking of doing it with switch but didn't found any DAX function that can help to come out of switch after 1st condition is satisfied(for Year) .It goes on to check all conditions and provide the last one that come as true.

I have tried with switch and looping nested ifs , but it is also behaving same way.
WHAT I WANT IS if i select year slicer as 2020(it should show YTD for 2020 in card), and when i move to next slicer Quarter -2 , then card visual should show QTD  for 2020-Q2.


SBDT_SALES_IFELSEselection =
var _SBDT_year_SELECTION = SELECTEDVALUE(SALES_Date_DIM[Year])
var _SBDT_quarter_SELECTION = SELECTEDVALUE(SALES_Date_DIM[Quarter])
RETURN
switch(
true(),
IF(
and(_SBDT_year_SELECTION in values(SALES_Date_DIM[year]), _SBDT_quarter_SELECTION in values(SALES_Date_DIM[Quarter])), [Gross_Sales_QTD],000),
IF(
_SBDT_year_SELECTION in values(SALES_Date_DIM[Year]),[Gross_Sales_YTD],
000
))

Any help on this will be appreciated.Thanks

3 REPLIES 3
BI_Power_Guy
Frequent Visitor

@amitchandak @rbriga Thanks both for the quick response , Actually i don't want slicers for YTD ,QTD,MTD .I want the card to pick values automatically if i select a year slicer (YTD it should pick for that year, example 2020 YTD),and then when i move to quarter slicer(same card visual should pick QTD, example 2020 Q2 ).

so measure selection doesn't fit my requirement and calculated group , i have created , it is working fine in a matrix , but not in a card visual .Below i am attaching a snippet of want i want .(when card visual will become dynamic , i will go on to make card title dynamic as well).

If you know any other cool trick for this , will appreiate if you can share pbix file here.

And @amitchandak  have subcribed your channel 🙂

BI_Power_Guy_0-1648117742163.png

BI_Power_Guy_1-1648118128017.png

 

amitchandak
Super User
Super User

@BI_Power_Guy , I think you need to measure slicer or calculation group

 

measure slicer
https://www.youtube.com/watch?v=b9352Vxuj-M
https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...
https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slic...
https://www.youtube.com/watch?v=vlnx7QUVYME

 

or

 

Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
rbriga
Impactful Individual
Impactful Individual

Seconding @amitchandak , I would use a calculated group (requires Tabular Editor).

You can create calculated items for YTD, QTD, MTD, and name the field "Period".

Now, in the visual, you may put the measure you want to show, and make "Period" your single-selection slicer.

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors