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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
houba139
Frequent Visitor

Actual (DirectQuery) vs. Target1 and Target2 (Import)

Hi, can anybody help with dax definition?

 

I'm stuck with connecting targets and actuals. The goal is to conditionally format actual values as per target values.

 

houba139_0-1677850624946.png

 

 

 

houba139_0-1677849738550.png

1:1 relationship

 

Is this even achievable, meaning combining data from DQ and Import mode? 

 

 

Thank you.

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @houba139 

You can refer to the following example

1.You can create a measure

Measure = var a=CALCULATE(SUM('Table (2)'[Target1]),FILTER('Table (2)',[SensorID]=MAX('Table'[SensorID])))
var b=CALCULATE(SUM('Table (2)'[Target2]),FILTER('Table (2)',[SensorID]=MAX('Table'[SensorID])))
return SWITCH(TRUE(),MAX('Table'[Value])<a,-1,MAX('Table'[Value])>=a&&MAX('Table'[Value])<b,0,MAX('Table'[Value])>=b,1)

Output

vxinruzhumsft_0-1678066834985.png

 

2.You can create a calculated table

Table 2 = ADDCOLUMNS('Table',"Judgement",SWITCH(TRUE(),'Table'[Value]<CALCULATE(SUM('Table (2)'[Target1]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID]))),-1,'Table'[Value]>=CALCULATE(SUM('Table (2)'[Target1]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID])))&&'Table'[Value]<CALCULATE(SUM('Table (2)'[Target2]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID]))),0,'Table'[Value]>=CALCULATE(SUM('Table (2)'[Target2]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID]))),1))

vxinruzhumsft_1-1678066983636.png

 

Best Regards!

Yolo Zhu

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

 

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @houba139 

You can refer to the following example

1.You can create a measure

Measure = var a=CALCULATE(SUM('Table (2)'[Target1]),FILTER('Table (2)',[SensorID]=MAX('Table'[SensorID])))
var b=CALCULATE(SUM('Table (2)'[Target2]),FILTER('Table (2)',[SensorID]=MAX('Table'[SensorID])))
return SWITCH(TRUE(),MAX('Table'[Value])<a,-1,MAX('Table'[Value])>=a&&MAX('Table'[Value])<b,0,MAX('Table'[Value])>=b,1)

Output

vxinruzhumsft_0-1678066834985.png

 

2.You can create a calculated table

Table 2 = ADDCOLUMNS('Table',"Judgement",SWITCH(TRUE(),'Table'[Value]<CALCULATE(SUM('Table (2)'[Target1]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID]))),-1,'Table'[Value]>=CALCULATE(SUM('Table (2)'[Target1]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID])))&&'Table'[Value]<CALCULATE(SUM('Table (2)'[Target2]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID]))),0,'Table'[Value]>=CALCULATE(SUM('Table (2)'[Target2]),FILTER('Table (2)',[SensorID]=EARLIER('Table'[SensorID]))),1))

vxinruzhumsft_1-1678066983636.png

 

Best Regards!

Yolo Zhu

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

 

Thank you, it works!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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