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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
luisajara10
Frequent Visitor

hasonefilter power bi

Good day,

I am using the following formula:

measureName = IF(HASONEFILTER('TableA'[Date].[Year]),SUM('TableA'[numbers]),BLANK())

This measure brings information if the year is pressed, I need help with the following:
If the data segmentation of the year is pressed, it does not show any results and if it is pressed, only the month does not show any results, it should only show information if the year and month are pressed at the same time.

thank you.

2 ACCEPTED SOLUTIONS

Hello, thanks for answering.

I solved it in the following way.

I added the following to the function: &&HASONEFILTER(Calendar[Date].[Month])

It remained like this:

IF(HASONEFILTER('TableA'[Date].[Year])&& (HASONEFILTER('TableA'[Date].[Month]),SUM('TableA'[numbers]),BLANK())

I force the year and month segmentation buttons to be selected, if one is not selected, it does not show information.

View solution in original post

Hello, thanks for replying.

Fix it as follows.

add the following to the function: &&HASONEFILTER(Calendar[Date].[ Month])

It looks like this:

IF(HASONEFILTER('Table'[date].[ Year])&& (HASONEFILTER('Tablea'[date].[ Month]),SUM('TableA'[numbers]),BLANK())

I force that the year and month segmentation buttons are selected, if any is not selected it does not show information.

View solution in original post

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

Nice day

I am using the following formula:

nameMeasure = IF(HASONEFILTER('TableA'[Date].[ Year]),SUM('TableA'[numbers]),BLANK())

This measure brings information if the year is pressed, I need help with the following:
if the year slicer is pressed does not show any results and if it is pressed only month does not show any results, it should only show information if it is pressed year and month at the same time.

Thanks a lot.

@Syndicate_Admin , better you create a new column year column and use that

 

Year = Year([Date])

 

 

then

nameMeasure = IF(HASONEFILTER('TableA'[ Year]),SUM('TableA'[numbers]),BLANK())

 

also refer

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hello, thanks for replying.

Fix it as follows.

add the following to the function: &&HASONEFILTER(Calendar[Date].[ Month])

It looks like this:

IF(HASONEFILTER('Table'[date].[ Year])&& (HASONEFILTER('Tablea'[date].[ Month]),SUM('TableA'[numbers]),BLANK())

I force that the year and month segmentation buttons are selected, if any is not selected it does not show information.

amitchandak
Super User
Super User

@luisajara10 ,

better you create a new column year column and use that

 

Year = Year([Date])

 

 

then

measureName = IF(HASONEFILTER('TableA'[Year]),SUM('TableA'[numbers]),BLANK())

 

refer

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hello, thanks for answering.

I solved it in the following way.

I added the following to the function: &&HASONEFILTER(Calendar[Date].[Month])

It remained like this:

IF(HASONEFILTER('TableA'[Date].[Year])&& (HASONEFILTER('TableA'[Date].[Month]),SUM('TableA'[numbers]),BLANK())

I force the year and month segmentation buttons to be selected, if one is not selected, it does not show information.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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