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
anjanikumar
Helper II
Helper II

Convert this SQL query to DAX measure

select opportunity_status, sum(opportunity_value) as sum_opp_value from (

select distinct opportunity_id , opportunity_status ,opportunity_value

from web_analytics_dm.dm_behaviour_campaign_salesforce dbcs

where  business_unit='SEF'

and "date"='20211201') a

group by opportunity_status

3 REPLIES 3
Anonymous
Not applicable

Hi @anjanikumar ,

 

You may try this measure

Measure=
VAR _table =
    FILTER (
        DISTINCT ( 'web_analytics_dm.dm_behaviour_campaign_salesforce dbcs' ),
        [date] = DATE ( 2021, 12, 1 )
            && [business_unit] = "SEF"
    )
RETURN
    CALCULATE (
        SUM ( 'web_analytics_dm.dm_behaviour_campaign_salesforce dbcs'[opportunity_value] ),
        FILTER (
            _table,
            [opportunity_status]
                = MAX ( 'web_analytics_dm.dm_behaviour_campaign_salesforce dbcs'[opportunity_status] )
        )
    )

 

If that doesn't work, hope to provide some dummy data and expected results.

 

 

Best Regards,

Stephen Tao

 

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

amitchandak
Super User
Super User

@anjanikumar , You can create a measure like

 

sumx(summarize(filter(dm_behaviour_campaign_salesforce, [business_unit]="SEF" && [date]= Date(2021,12,01)), [opportunity_id] , [opportunity_status] ,[opportunity_value]), [opportunity_value])

 

and use with opportunity_status is any visual

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

@amitchandak 

 

Thank you so much for your response !!

 

want opportunity_status  with Groupby .

 

Convert below query as DAX.

 

select opportunity_status, sum(opportunity_value) as sum_opp_value from (

select distinct opportunity_id , opportunity_status ,opportunity_value

from web_analytics_dm.dm_behaviour_campaign_salesforce dbcs

group by opportunity_status

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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