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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
omelo
Helper III
Helper III

Distinct Count and count user choice

Hi,

I'm creating a report and would need to give the users the option to include or exclude sub-projects in the project count.

The data is something like:

 

Project   Sub-project

1004

1004          001

1005

1006

 

If selecting to include sub-project, I would use count, the result would be 4.

If selecting no to include sub-projects, I would use count distinct, the result would be 3

 

I've tried creating a mesure, but I realized that  a measure can't be used to filter at the report level.

 

Is there a way to accomplish this, other than creating a dupplicate page and assign the value as needed.

Thank you for your help

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@omelo ,You need to switch between two measure based on isfiltered

 

measure =

var _tab = summarize(Table, Table[project], Table[Project Sub-project])

return

countx(_tab, Table[project])

 

measure 1 = distinctcount(Table[project])

 

final measure = if(isfiltered (Table[Project Sub-project]), [measure], [measure1])

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@omelo ,You need to switch between two measure based on isfiltered

 

measure =

var _tab = summarize(Table, Table[project], Table[Project Sub-project])

return

countx(_tab, Table[project])

 

measure 1 = distinctcount(Table[project])

 

final measure = if(isfiltered (Table[Project Sub-project]), [measure], [measure1])

 

Hi,

I was not familiar with the switch function but thanks to your response I was able to find a video that gave me the details that I needed.
I'm including the link in case someone else is looking to do the same.
Dynamically change the information within a visual via a slicer - oxcrx34285 (powerbi.com)

 

Again, many thanks for your response

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.