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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
SaiyedAlam
Regular Visitor

Need DAX from PostgreSql query

Hi, This is Alam here, I am sort of new to Power BI and this DAX stuff. Although it is very interesting at the same time i'm getting stuck in certain cases where I am finding any proper resources to solve my problem. I would really appreciate if anyone can help me convert the following PostgreSql query into DAX. The query is:

WITH CurrentWeek AS (

SELECT DISTINCT id, sample_requested_by

FROM designer_activity_dashboard_view

where publish_date >= date_trunc('week', CURRENT_DATE)

AND publish_date < date_trunc('week', CURRENT_DATE) + INTERVAL '7 days'

 

 

)

SELECT sample_requested_by, cuv.name , COUNT(*) AS This_Week_TechPack_Published

FROM CurrentWeek

JOIN crm_user_view cuv ON CurrentWeek.sample_requested_by = cuv.id

GROUP BY sample_requested_by, cuv.name

ORDER BY sample_requested_by

 
Would really appreciate your quick response and thanks in advance 

Sincerely 
Alam

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SaiyedAlam ,

You can create a measure as below to get it:

Measure =
VAR _selid =
    SELECTEDVALUE ( 'crm_user_view'[id] )
VAR _selname =
    SELECTEDVALUE ( 'crm_user_view'[name] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'designer_activity_dashboard_view'[sample_requested_by] ),
        FILTER (
            'designer_activity_dashboard_view',
            'designer_activity_dashboard_view'[publish_date]
                >= TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
                && 'designer_activity_dashboard_view'[publish_date]
                    <= TODAY ()
                        + ( 7 - WEEKDAY ( TODAY (), 2 ) )
        )
    )
RETURN
    CALCULATE (
        COUNT ( 'crm_user_view'[id] ),
        FILTER ( 'crm_user_view', 'crm_user_view'[id] IN _tab )
    )

Then create a table visual with the Fields settings as below screenshot:

vyiruanmsft_0-1680575916630.png

If the above one can't help you get the expected result, could you please provide some raw data in the table 'designer_activity_dashboard_view'  and 'crm_user_view' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @SaiyedAlam ,

You can create a measure as below to get it:

Measure =
VAR _selid =
    SELECTEDVALUE ( 'crm_user_view'[id] )
VAR _selname =
    SELECTEDVALUE ( 'crm_user_view'[name] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'designer_activity_dashboard_view'[sample_requested_by] ),
        FILTER (
            'designer_activity_dashboard_view',
            'designer_activity_dashboard_view'[publish_date]
                >= TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
                && 'designer_activity_dashboard_view'[publish_date]
                    <= TODAY ()
                        + ( 7 - WEEKDAY ( TODAY (), 2 ) )
        )
    )
RETURN
    CALCULATE (
        COUNT ( 'crm_user_view'[id] ),
        FILTER ( 'crm_user_view', 'crm_user_view'[id] IN _tab )
    )

Then create a table visual with the Fields settings as below screenshot:

vyiruanmsft_0-1680575916630.png

If the above one can't help you get the expected result, could you please provide some raw data in the table 'designer_activity_dashboard_view'  and 'crm_user_view' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.