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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Shashanth
Frequent Visitor

Need help on a Measure

Hi All,

 

I am trying to get the Product_id_count with a few filters. But which ever method I try, I am not able to get it.

 

 
I have 2 summarized tables ; calculated_Product_rating_table and calculated_service_rating_table. Both are are tables from a main table in the direct query mode.
It is only these 2 tables that are summarized which is causing the storage mode to be Mixed(not sure if this info makes any difference to the answer, but just mentioning it for better clarity). The common field is product_id.
 

 

My requirement is to get the distinct count of product_id's

where 

(calculated_Product_rating_table[Overall_Approval__Rate>60%]=TRUE

or

calculated_Product_rating_table[TV_Approval__Rate>50%]=TRUE

or

calculated_service_rating_table[TV Repeat >= 150%])=TRUE

or

calculated_service_rating_table[Overall Repeat >= 300%])=TRUE)

 

I tried the below formulas but none of them worked, all gave me one or the other error. Hence asking you for help.

 

product_id_count = CALCULATE(DISTINCTCOUNTNOBLANK(calculated_Product_rating_table[product_id]),OR(or(calculated_Product_rating_table[Overall_Approval__Rate>60%]=TRUE,calculated_Product_rating_table[TV_Approval__Rate>50%]=TRUE),or(LOOKUPVALUE(calculated_service_rating_table[Overall Repeat >= 300%],calculated_Product_rating_table[product_id],calculated_service_rating_table[product_id])=TRUE,LOOKUPVALUE(calculated_service_rating_table[TV Repeat >= 150%],calculated_Product_rating_table[product_id],calculated_service_rating_table[product_id])=TRUE)))
 
product_id_count = CALCULATE(DISTINCTCOUNTNOBLANK(calculated_Product_rating_table[product_id]),or(or(calculated_Product_rating_table[Overall_Approval__Rate>60%]=TRUE,calculated_Product_rating_table[TV_Approval__Rate>50%]=TRUE),(or(related(calculated_service_rating_table[TV Repeat >= 150%])=TRUE,related(calculated_service_rating_table[Overall Repeat >= 300%])=TRUE))))
 
product_id_count =
CALCULATE(DISTINCTCOUNTNOBLANK(calculated_Product_rating_table[product_id]),or((FILTER(calculated_Product_rating_table,or(calculated_Product_rating_table[Overall_Approval__Rate>60%]=TRUE,calculated_Product_rating_table[TV_Approval__Rate>50%]=TRUE))),(FILTER(calculated_service_rating_table,or(calculated_service_rating_table[TV Repeat >= 150%]=TRUE,calculated_service_rating_table[Overall Repeat >= 300%]=TRUE)))))
 
product_id_count =
CALCULATE(DISTINCTCOUNTNOBLANK(calculated_Product_rating_table[product_id]),
or(calculated_Product_rating_table[Overall_Approval__Rate>60%]=TRUE,or(calculated_Product_rating_table[TV_Approval__Rate>50%]=TRUE,or(calculated_service_rating_table[TV Repeat >= 150%]=true,calculated_service_rating_table[Overall Repeat >= 300%]=true))))
 
 
Shashanth_1-1623145635252.png

 


Regards

-Shashanth

1 ACCEPTED SOLUTION
Shashanth
Frequent Visitor

Guys, I was able to find a solution. A collegue of mine helped me.

 

Basically we created an other table WITHOUT USING SUMMARIZE(I did not know this was possible/allowed)

 

Final_Table = DISTINCT(calculated_Product_rating_table[product_id])
 
and added all the columns that I wanted to add a filter on,
 
[Overall Repeat___rate >= 300%] = LOOKUPVALUE(calculated_service_rating_table[Overall Repeat >= 300%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
Overall_Approval___Rate>60% = LOOKUPVALUE(calculated_Product_rating_table[Overall_Approval__Rate>60%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
[TV Repeat___rate >= 150%] = LOOKUPVALUE(calculated_service_rating_table[TV Repeat >= 150%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
TV_Approval___Rate>50% = LOOKUPVALUE(calculated_Product_rating_table[TV_Approval__Rate>50%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
And finally created a column with an OR function, that I finally wanted
 
Required product_id's = or(Final_Table[Overall Repeat___rate >= 300%]=true,or(Final_Table[TV_Approval___Rate>50%]=true,or(Final_Table[Overall Repeat___rate >= 300%]=true,Final_Table[TV Repeat___rate >= 150%]=true)))
 
and created a measure on it
 
product_id_count = CALCULATE(DISTINCTCOUNT(Final_Table[product_id]),Final_Table[Required FSN's]=true)
 
Shashanth_0-1623239186520.png

 

Thanks to him. FInally I was able to do it.
 
Regards
-Shashanth

View solution in original post

3 REPLIES 3
Shashanth
Frequent Visitor

Guys, I was able to find a solution. A collegue of mine helped me.

 

Basically we created an other table WITHOUT USING SUMMARIZE(I did not know this was possible/allowed)

 

Final_Table = DISTINCT(calculated_Product_rating_table[product_id])
 
and added all the columns that I wanted to add a filter on,
 
[Overall Repeat___rate >= 300%] = LOOKUPVALUE(calculated_service_rating_table[Overall Repeat >= 300%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
Overall_Approval___Rate>60% = LOOKUPVALUE(calculated_Product_rating_table[Overall_Approval__Rate>60%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
[TV Repeat___rate >= 150%] = LOOKUPVALUE(calculated_service_rating_table[TV Repeat >= 150%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
TV_Approval___Rate>50% = LOOKUPVALUE(calculated_Product_rating_table[TV_Approval__Rate>50%],calculated_Product_rating_table[product_id],Final_Table[product_id])
 
And finally created a column with an OR function, that I finally wanted
 
Required product_id's = or(Final_Table[Overall Repeat___rate >= 300%]=true,or(Final_Table[TV_Approval___Rate>50%]=true,or(Final_Table[Overall Repeat___rate >= 300%]=true,Final_Table[TV Repeat___rate >= 150%]=true)))
 
and created a measure on it
 
product_id_count = CALCULATE(DISTINCTCOUNT(Final_Table[product_id]),Final_Table[Required FSN's]=true)
 
Shashanth_0-1623239186520.png

 

Thanks to him. FInally I was able to do it.
 
Regards
-Shashanth
amitchandak
Super User
Super User

@Shashanth , Try like

 

product_id_count = CALCULATE(DISTINCTCOUNTNOBLANK(calculated_Product_rating_table[product_id]),filter(values(calculated_Product_rating_table[product_id]), OR(or(calculated_Product_rating_table[Overall_Approval__Rate>60%]=TRUE,calculated_Product_rating_table[TV_Approval__Rate>50%]=TRUE),or(LOOKUPVALUE(calculated_service_rating_table[Overall Repeat >= 300%],calculated_Product_rating_table[product_id],calculated_service_rating_table[product_id])=TRUE,LOOKUPVALUE(calculated_service_rating_table[TV Repeat >= 150%],calculated_Product_rating_table[product_id],calculated_service_rating_table[product_id])=TRUE))))

 

or

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

Hi Amit,

 

Thanx for your response.

I am not able to get this working.

 

Shashanth_0-1623157327673.png

Still not sure what the error is.

 

And wrt sharing a sample file, I am not able to do it since it is a direct query mode to the servers with lot of data.

 

Is there any ther solution that you can help me out with?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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