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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
rajatsharma1987
Frequent Visitor

Removing the filters on table and then filtering it based on different table's col.

I have 3 tables as below, Table1 is connected to table2 with bidirectional filtering and Table2 is connected to Datedim.

Now , I want to count and  filter like below from table1:

Count Table1[Aptid] where Table1[Case_type] = "u" and datedim[Year] = 2023

 

Count of "u" should be 3 as in 2023 there are 3 "u".

 

I am using below query which returns count as 2 as table 2 has only 2 rows of "u"

 

table1_Case_Created_USD =
Var Year1 = if(MONTH(TODAY()) >9 ,"FY" & RIGHT(YEAR(TODAY()),2)+1,"FY" & RIGHT(YEAR(TODAY()),2))

VAR Count1 =CALCULATE(DISTINCTCOUNT(table1[CASE_ID_Primary]),table1[New_Case_type] ="USD - Unauthorized Software Detected",DateDim[year] = Year1)
RETURN
IF(ISBLANK(count1),0,Count1)

 

Table1  
aptidcase_typedate
1u10/11/2023
2u10/12/2023
3u10/13/2023
4u10/14/2024
5a10/15/2023
6a10/16/2024

 

 

Table2 
aptiddate
110/11/2023
210/12/2023
510/15/2023

 

 

datedim 
dateyear
10/11/20232023
10/12/20232023
10/13/20232023
10/14/20232024
10/15/20232023
10/16/20232023
10/16/20242024

 

4 REPLIES 4
Dangar332
Memorable Member
Memorable Member

hi, @rajatsharma1987 

try below 

coun = CALCULATE(COUNT(Table1[aptid]),
                        Table1[case_type]="u",
                         ALLCROSSFILTERED(datedim),
                        TREATAS(VALUES(datedim[date]),Table1[date])
                        )
Dangar332_0-1697179305994.png

 

i am upload pbix. file refer here 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

Hi @Danger332, I am creating a calculated field for Year till date (YTD) therefore I cannot use the filter outside the calculated field. So "datedim = Year1" should be used in the calculation.

rajatsharma1987
Frequent Visitor

No , I cannot change the dependencies due to other dependencies.

Dangar332
Memorable Member
Memorable Member

hi, @rajatsharma1987 
is there any chance to adjust relationship bw your table?

 

if yes then make your data model like below 

Dangar332_0-1697130065377.png

 

 

it give your desired output. 

Dangar332_0-1697130698951.png

 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors