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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
ABC11
Resolver I
Resolver I

Need help on DAX function with measure vs column

Hello,

Lastest_WorkDate = CALCULATE(MAX(LEM_FACTS[WORKDATE]))-this is measure column
NO_OF_DAYS_Running Behind = DATEDIFF(LEM_FACTS[Lastest_WorkDate],TODAY(),DAY)-this is measure column
Level_1 =Switch( true(),
LEM_FACTS[NO_OF_DAYS_Running Behind]4,"GOOD",
LEM_FACTS[NO_OF_DAYS_Running Behind]<7,"Email Vendor", LEM_FACTS[NO_OF_DAYS_Running Behind]<21,"Action Immediately", LEM_FACTS[NO_OF_DAYS_Running Behind]<61,"Check to see if it's on site","Off Site")

This is working perfectly fine as measure column but when I do as add column its not.

ABC11_1-1649968325525.png

I need to do column because I need to do graph as well.

Any help would be appriciate.

Thanks,

 

14 REPLIES 14
SpartaBI
Community Champion
Community Champion

Hey @ABC11 ,
Just wrtie this funcion in a new column (I've put everyhing in one column):
Level 1 = 
VAR _Lastest_WorkDate =  LEM_FACTS[WORKDATE]
VAR _Diff = DATEDIFF(Lastest_WorkDate,TODAY(),DAY)
VAR _Result =
switch(
 
true(),

_Diff < 4,"GOOD",
_Diff<7,"Email Vendor",
_Diff<21,"Action Immediately",
_Diff<61,"Check to see if it's on site",
"Off Site")
RETURN
_Result


Hope this helps

Hello,

I am getting this error" Failed to resolve name 'LEM_FACTS'. It is not a valid table, variable, or function name." My table bname is this for sure

Please

Thanks for your time

 

SpartaBI
Community Champion
Community Champion

Check now, had a typo, I edited it

Thanks its worked.

but something is not working. Total I have 102 contract.  

ABC11_0-1650308561104.png

 

SpartaBI
Community Champion
Community Champion

I need more info.

Pay attenation that the solution was for a calculated column. Check that the result is correct in the data tab view. You showes a screenshot of a visual which is an aggregation on top of what we did and it depends on the filter context generated by the visual and also on the summarization of the column ( i see count, maybe you wanted sum)

I would like to count (no of vendor(CNRCNSUM)) who fall under those five categary. Total I have 102 CNRCNSUM. 

This report suppose to show me - each vendor(or contract no) submit their lastest workdate invocie(we call as LEM). So we calculated maximum workdate. then we calculated no of days running behind. and then five categaroy.

For Business summary - I would like to show how many vendor fall under which categary. 

Would you help me please

SpartaBI
Community Champion
Community Champion

I'm sorry

I need to see exactly the data, it's already deviated a lot from what I thought was the question. PM me if you want

@vojtechsima any ideas on what is missing from our replies so far?

How can I share my data. How/where I can upload my file PBI file

@ABC11 Hi, 
you can share your model as Screenshot of Model in Power BI Desktop and sample data by pasting a raw data here in comments like this:

Data Data2 Something More
456 KDAa Something Else
456853 DSA Yes
913250 KDAa No
1369647 DSA Something Else
1826044 KDAa Yes
2282441 DSA No
2738838 KDAa Something Else
3195235 DSA Yes
3651632 KDAa No
4108029 DSA Something Else



Ideally, if you can upload your file to OneDrive (or Google Drive) and share the link, that would be awesome, if you have sensitive data, please re-create your file using random values, keep the structure and model and send it like this.

SITEIDVENDOR_NAMECNRCMSNUMDESCRIPTIONLastest_WorkDateNO_OF_DAYS_Running BehindLevel
HORIZONABCC0160722Acden - Light Vehicle Fleet and HD Equipment Mtc - Horizon4/13/2022 0:005Email Vendor
HORIZONXYZCTR0174983Acden Facilities - HVAC Maintenance - Horizon4/13/2022 0:005Email Vendor
HORIZONPQRCTR0242927Acuren - NDE, NDT, Rope Access - Horizon4/14/2022 0:004Email Vendor
HORIZONACTR0109798Acuren - NDE, NDT, Rope Access - Horizon - CLOSED USE CTR0242921/30/2022 0:0078Off Site
HORIZONB823350-48Air Chek - Master Engineering Services - Horizon9/13/2021 0:00217Off Site
HORIZONCCTR015599Air Liquide - Nitrogen Pumping Services - Horizon9/29/2021 0:00201Off Site
HORIZONDCTR017966Aker - Asset Integrity Services - Horizon4/16/2022 0:002GOOD
HORIZONGCTR019158Altex - Exchanger Bundle Pulling - Horizon4/12/2022 0:006Email Vendor
HORIZONHCTR024121ATI CANADA - MAINTENANCE LABOUR - HORIZON3/22/2022 0:0027Check to see if it's on site
HORIZONGCTR010676Belterra - Belt Installation, Mtc., Repair - Horizon4/7/2022 0:0011Action Immediately
HORIZONKCTR016310Black McDonald - Mechanical Maintenance - Horizon4/6/2022 0:0012Action Immediately
HORIZONLCTR017182Blackstone - Rotating Equipment Maintenance - Horizon4/14/2022 0:004Email Vendor
HORIZONDCTR013515Bouchier Contracting - Roads, Grounds, Fire Water Mtc. - Horizon4/15/2022 0:003GOOD
HORIZONTCTR016519Bouchier Site Services- Facility Maintenance - Horizon4/16/2022 0:002GOOD
HORIZONCCTR015845Brock Canada - Scaffold Rentals - Horizon2/26/2022 0:0051Check to see if it's on site
HORIZONA1CTR016786CANOCO ENERGY - Maintenance - Welding & Pipefitting - Horizon4/3/2022 0:0015Action Immediately
HORIZONB2CTR018007Ceda - Dredging and Dewatering - Horizon4/12/2022 0:006Email Vendor
HORIZONC3CTR009028Ceda - P&V Industrial Cleaning and Mechanical - Horizon3/4/2022 0:0045Check to see if it's on site
HORIZONG5821089Challenger - Survey Services - Horizon3/24/2022 0:0025Check to see if it's on site

Hello Vojtechsima,

does this data help you? do you want something more? please, let me know

Thanks

SpartaBI
Community Champion
Community Champion

Strange. Can you share your file here?

vojtechsima
Super User
Super User

Hi, @ABC11 
Could you please clarify more clearly why and what it's not working? I suppose I don't see the problem you're talking about.

Thanks to Vojtechsima.

Everthing is working in measaure column. I need to do these as add column becuase I need to draw graph(pie) and do the summary report as %. In order to do that I need this calculation as column (not measure) 

Please, help me

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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