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
_Regina
Helper I
Helper I

Help to create a measure with multiple conditions from various tables

Hi Everyone- here is what I am trying to do
 
I need to get the number of clients who have a total sales of 1000 dollars during certain time period, their application must have been submitted during certain time period, and they must have been referred during certain time period. My data model has a sales table(transaction), application table, refrral table
 
I tried the following measure with test dates, but I get the error 
A table of multiple values was supplied where a single value was expected
 
Could anyone help me with the measure that I am trying to build here.
 
test_Clients funded with $1000 by March 31 from the Referrals =
VAR _start_date = 
   CALCULATE ( MIN ( '_date unpivot'[Date Key] ) )
VAR _end_date =
  CALCULATE ( MAX ( '_date unpivot'[Date Key] ) )

VAR _transaction =    FILTER('transaction',DATESBETWEEN('transaction'[Processing Date],DATE(2022,10,01),DATE(2022,10,31)))

VAR _application =    FILTER('application','application'[Submit Date] <= DATE(2022,10,01))

VAR _referral =    FILTER('referral', DATESBETWEEN ( referral[Created Date], _start_date, _end_date ))

var net_sales=ADDCOLUMNS(CALCULATETABLE( FILTER(SUMMARIZE('transaction','transaction'[Client ID],"NetSalesbyMarch31",SUM('transaction'[Amount])),[NetSalesbyMarch31]>=1000),KEEPFILTERS(_transaction),KEEPFILTERS(_application)
,KEEPFILTERS(_referral)
),"countclient",1)  

VAR r =
    SUMX(net_sales,[countclient])
RETURN
    r
2 REPLIES 2
Anonymous
Not applicable

Hi  @_Regina ,

You can modify DAX to the following:

test_Clients funded with $1000 by March 31 from the Referrals =
VAR _start_date =
    MINX ( ALL ( '_date unpivot' ), [Date Key] )
VAR _end_date =
    MAXX ( ALL ( '_date unpivot' ), [Date Key] )
VAR _transaction =
    FILTER (
        ALL ( 'transaction' ),
        DATESBETWEEN (
            'transaction'[Processing Date],
            DATE ( 2022, 10, 01 ),
            DATE ( 2022, 10, 31 )
        )
    )
VAR _application =
    FILTER (
        ALL ( 'application' ),
        'application'[Submit Date] <= DATE ( 2022, 10, 01 )
    )
VAR _referral =
    FILTER (
        ALL ( 'referral' ),
        DATESBETWEEN ( referral[Created Date], _start_date, _end_date )
    )
VAR net_sales =
    ADDCOLUMNS (
        CALCULATETABLE (
            FILTER (
                SUMMARIZE (
                    'transaction',
                    'transaction'[Client ID],
                    "NetSalesbyMarch31", SUM ( 'transaction'[Amount] )
                ),
                [NetSalesbyMarch31] >= 1000
            ),
            KEEPFILTERS ( _transaction ),
            KEEPFILTERS ( _application ),
            KEEPFILTERS ( _referral )
       ),
        "countclient", 1
    )
VAR r =
    SUMX ( net_sales, [countclient] )
RETURN
    r

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

FreemanZ
Super User
Super User

what is "[countclient]" in your case?

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.