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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Most Efficient Query

Hello All, 

 

Im trying to get an output of 0 or 1 for flag using a calculated column, code: 

 

CI_c =
if(SUMX(
SUMMARIZE(
CI,
CI[PPLCODE],
"sum of data", CALCULATE(COUNT(CI[PPLCODE]), FILTER(CI, CI[PPLCODE]='IRR Retina'[PPL CD]
&& CI[UPDATED_ON_DT].[Date]>'IRR Retina'[Contract Start Date_c]&& CI[UPDATED_ON_DT].[Date]<='IRR Retina'[Transaction date_c]
))),
[sum of data]
)>0,1,0)
 
Can someone help optimize this for me, im not sure where to begin. 
 
Thanks,
Matt 
1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

 

Please try this Calculated column.

CI_c =

IF (

    CALCULATE (

        COUNT ( CI[PPLCODE] ),

        FILTER (

            CI,

            CI[PPLCODE] = 'IRR Retina'[PPL CD]

                && CI[UPDATED_ON_DT].[Date] > 'IRR Retina'[Contract Start Date_c]

                && CI[UPDATED_ON_DT].[Date] <= 'IRR Retina'[Transaction date_c]

        )

    ) > 0,

    1,

    0

)

 

Then, the result should look like this.

vcazhengmsft_1-1641545215394.png

 

Attached the pbix file as reference. If it doesn’t work, could you please provide some sample data used by this formula and let me know the relationship between your tables? Thanks in advance!

 

In addition, you can use Performance Analyzer to help you optimize your calculation. For more details about Performance Analyzer, please refer to Use Performance Analyzer to examine report element performance.

 

Best Regards,

Community Support Team _ Caiyun

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

 

 

View solution in original post

2 REPLIES 2
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

 

Please try this Calculated column.

CI_c =

IF (

    CALCULATE (

        COUNT ( CI[PPLCODE] ),

        FILTER (

            CI,

            CI[PPLCODE] = 'IRR Retina'[PPL CD]

                && CI[UPDATED_ON_DT].[Date] > 'IRR Retina'[Contract Start Date_c]

                && CI[UPDATED_ON_DT].[Date] <= 'IRR Retina'[Transaction date_c]

        )

    ) > 0,

    1,

    0

)

 

Then, the result should look like this.

vcazhengmsft_1-1641545215394.png

 

Attached the pbix file as reference. If it doesn’t work, could you please provide some sample data used by this formula and let me know the relationship between your tables? Thanks in advance!

 

In addition, you can use Performance Analyzer to help you optimize your calculation. For more details about Performance Analyzer, please refer to Use Performance Analyzer to examine report element performance.

 

Best Regards,

Community Support Team _ Caiyun

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

 

 

VahidDM
Super User
Super User

Hi @Anonymous 

 

Can you post sample data as text and expected output?

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
4. Relation between your tables

Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

 

New Year Power BI eCard:

 

https://community.powerbi.com/t5/Data-Stories-Gallery/Happy-New-Year/td-p/2266398

 

 

 

eb50dd_d85fbe053af7491e915ca41732d978a7~mv2

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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