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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Nimai123
Post Patron
Post Patron

Dynamic Measure and Slicer

Hello Guys,

 

I want to create a dynamic measure which depends on the slicer.

 

When I select 19-20 my measure will show the data for that year

Capture1.PNG

When I select 20-21 my measure will show the data for that year

Capture.PNG

 

But when I select more than 2 years I get a blank result.

Capture.PNG

 

How can i achieve that if i select 2 years in the slicer then i will get 2 lines for that 2 years selected and so on.

 

Volume KL Dynamic19-20 =
IF(SELECTEDVALUE('Calendar'[FY]) = "19-20",CALCULATE( SUMX(GRINetSalesDetailsBI,GRINetSalesDetailsBI[NetSales]/1000) ,'Calendar'[FY] = "19-20" ),BLANK())
 
Volume KL Dynamic 20-21 =
IF(SELECTEDVALUE('Calendar'[FY]) = "20-21",CALCULATE( SUMX(GRINetSalesDetailsBI,GRINetSalesDetailsBI[NetSales]/1000) ,'Calendar'[FY] = "20-21" ),BLANK())
 
1 ACCEPTED SOLUTION

@Nimai123 , for that you can add isfiltered or hasonevalue 

 

Volume KL Dynamic19-20 =
var _cnt = countx(filter(allselected('Calendar'[FY],'Calendar'[FY] ="19-20"),'Calendar'[FY])+0
return
IF(_cnt >0 && isfiltered ('Calendar'[FY]) ,CALCULATE( SUMX(GRINetSalesDetailsBI,GRINetSalesDetailsBI[NetSales]/1000) ,'Calendar'[FY] = "19-20" ),BLANK())

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Nimai123 , I am assuming you are hiding showing like based on selection. And each measure is a line

 

Volume KL Dynamic19-20 =
var _cnt = countx(filter(allselected('Calendar'[FY],'Calendar'[FY] ="19-20"),'Calendar'[FY])+0
return
IF(_cnt >0 ,CALCULATE( SUMX(GRINetSalesDetailsBI,GRINetSalesDetailsBI[NetSales]/1000) ,'Calendar'[FY] = "19-20" ),BLANK())

Volume KL Dynamic 20-21=
var _cnt = countx(filter(allselected('Calendar'[FY],'Calendar'[FY] ="20-21"),'Calendar'[FY])+0
return
IF(_cnt >0 ,CALCULATE( SUMX(GRINetSalesDetailsBI,GRINetSalesDetailsBI[NetSales]/1000) ,'Calendar'[FY] = "20-21" ),BLANK())

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

Hello @amitchandak 

 

Yes, I am hiding and showing based on the selection in the slicer and each line is a measure.

 

When I am not selecting any year from the slicer I should get a blank result, but I am getting both the lines by using the above measures

 

When I select 1 year I should get one line and when 2 I should get 2 lines and so on...

 

Capture.PNG

 

 

@Nimai123 , for that you can add isfiltered or hasonevalue 

 

Volume KL Dynamic19-20 =
var _cnt = countx(filter(allselected('Calendar'[FY],'Calendar'[FY] ="19-20"),'Calendar'[FY])+0
return
IF(_cnt >0 && isfiltered ('Calendar'[FY]) ,CALCULATE( SUMX(GRINetSalesDetailsBI,GRINetSalesDetailsBI[NetSales]/1000) ,'Calendar'[FY] = "19-20" ),BLANK())

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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 Kudoed Authors