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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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))
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

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))
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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.