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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
AgoO
New Member

what if scenarios with complex filtering

Hi everyone, 

 

I am setting up a scenario-testing with what if parameters. My modelling is related to school performance in certain fields to which multiple schools can contribute. I would like to be able to calculate measures based on user selection of parameters and schools, while keeping all other values constant.

 

My fact table is like the below:

Author                                PublicationID      Citations

BJ                                               A                    10

GT                                              A                    10

GT                                              B                      5

GT                                              C                      3

SR                                              A                    10

SR                                              C                      3

SR                                              D                      0 

 

And my dim table is the following: 

 

Author    School

BJ            School of Business          

GT           School of Medicine

SR           School of Medicine

 

One publication can belong to many authors and schools, authors & schools can have many publications and schools can have many authors.

(This is a simplified version of my model because I also have other dim tables and publicationIDs can belong to various fields. )

 

I want to calculate distinct count and other measures of publicationsIDs belonging to NON SELECTED schools.  

How can I count the publicationIDs where none of the authors belong to the selected school(s)? 

 

If I am calculating the number of PublicationIDs belonging to non-selected schools with the measure below publications that belong to both selected and non-selected schools are counted in, so this gives me an incorrect result: 

PubIDs of nonselected =

CALCULATE(DISTINCTCOUNT(my fact table'[PubID]), EXCEPT(ALL(my dim table[School]),ALLSELECTED(my dim table[School])))

 

Another failed solution: I have tried setting up a calculatedtable first to isolate the publicationIDs of selected school(s): 

IDsofselected = CALCULATETABLE(VALUES('my fact table'[PubID])) 

And then I've tried many ways to get the IDS that are all other IDs except the ones in this table. I experimented with EXCEPT&CALCULATETABLE, CROSSFILTER, TREATAS and creating a duplicate of the fact table to get the distinct count of publicationIDs belonging to NON SELECTED schools excluding those which also belong to selected schools. 

 

Any help is greatly appreciated. 

1 ACCEPTED SOLUTION

Thanks a lot Amit! I used your measure and modified it to get what I need the following way: 

PubIDlists =
var _IDsofselectedschool = CALCULATETABLE(VALUES(Rankings_metrics_QSTHE[PubID]),ALLSELECTED(Rankings_AuthorInternal[School/Department]))
var _IDs_allother = EXCEPT(CALCULATETABLE(VALUES(Rankings_metrics_QSTHE[PubID]), REMOVEFILTERS(Rankings_AuthorInternal[School/Department])), _IDsofselectedschool)
return
CALCULATE(DISTINCTCOUNT(Rankings_metrics_QSTHE[PubID]), filter(all(Rankings_metrics_QSTHE) , Rankings_metrics_QSTHE[PubID] in _IDs_allother))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@AgoO , you can try a measure like

Measure =
var _tab = EXCEPT(ALL('my dim table'[School]),ALLSELECTED('my dim table'[School]))
var _tab2 = summarize(filter('my dim table', 'my dim table'[School] in _tab ), [Author])
return
CALCULATE(DISTINCTCOUNT('my fact table'[PubID]), filter(all('my fact table'[Author]) , 'my fact table'[Author] in _tab2))

 

But these measure are suceessful my dim table is independent table do not join with fact

 

Refer this video

Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

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

Thanks a lot Amit! I used your measure and modified it to get what I need the following way: 

PubIDlists =
var _IDsofselectedschool = CALCULATETABLE(VALUES(Rankings_metrics_QSTHE[PubID]),ALLSELECTED(Rankings_AuthorInternal[School/Department]))
var _IDs_allother = EXCEPT(CALCULATETABLE(VALUES(Rankings_metrics_QSTHE[PubID]), REMOVEFILTERS(Rankings_AuthorInternal[School/Department])), _IDsofselectedschool)
return
CALCULATE(DISTINCTCOUNT(Rankings_metrics_QSTHE[PubID]), filter(all(Rankings_metrics_QSTHE) , Rankings_metrics_QSTHE[PubID] in _IDs_allother))

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.