cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
qlnv
New Member

A Single value for column in table cannot be determined

Hi, I'm trying to create a column/measure in direct query mode but it doesn't work. (it works in imported mode). 

The error: 

 

A single value for column 'NGAY_HL' in table 'BI_XE_HOP_DONG' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

My dax: 

 

DELTA_NGAY = if(DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY) > 0, IF(DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY)>'BI_XE_HOP_DONG'[PERIOD], 'BI_XE_HOP_DONG'[PERIOD],DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY)) ,0)

 

I want to create a column/measure check if NGAY_HL < TODAY and datediff of NGAY_HL and today > period then the result is period; Else, The result is DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY())

Thank you! 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@qlnv , This should work as a column , In case of measure you need to use aggregation on column or use them inside x functions

DELTA_NGAY = sumx('BI_XE_HOP_DONG',  if(DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY) > 0, IF(DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY)>'BI_XE_HOP_DONG'[PERIOD], 'BI_XE_HOP_DONG'[PERIOD],DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY)) ,0))

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@qlnv , This should work as a column , In case of measure you need to use aggregation on column or use them inside x functions

DELTA_NGAY = sumx('BI_XE_HOP_DONG',  if(DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY) > 0, IF(DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY)>'BI_XE_HOP_DONG'[PERIOD], 'BI_XE_HOP_DONG'[PERIOD],DATEDIFF('BI_XE_HOP_DONG'[NGAY_HL], TODAY(), DAY)) ,0))

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors