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
Anonymous
Not applicable

Need help with DAX

Hi Team ,
 
I am facing issue with the below mentioned DAX formula
 
CYCQCW-Win Rev = IF(and(AND([Fcst]="CQ",OR([SS_No]="07",[SS_No]="08")),[WEEK_NUM]= MAX(IF( [Fcst]="CQ",[WEEK_NUM],BLANK()))),[Rev$M],0)

2 issues i am facing here ,
  1. If I click on new measure and pasting the above formula its not at recognising the columns like FCST or Week Num .
  2. if I click on new column and paste it , here is the error what i am getting : "The Max function only accepts a column reference as an argument.

Thanks & Regards

Shiv

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

I wasn't quite sure what you wanted as a result (500 on every CQ? or a measure?)

Anyway here's a column:

ColumnX = var _fcst = TableA[FCST]
RETURN
IF (_fcst = "CQ",
CALCULATE(SUM(TableA[REVENUE]), 
    FILTER(TableA, TableA[WEEK] = 4 && TableA[STAGE] IN {"07", "08"} && TableA[FCST] = _fcst)))

If it's not quite what is required at least you can edit it for desired result

View solution in original post

5 REPLIES 5
HotChilli
Super User
Super User

I provided code for a column. I think you are creating a measure. That's OK but you'll need to make some changes.

HotChilli
Super User
Super User

I wasn't quite sure what you wanted as a result (500 on every CQ? or a measure?)

Anyway here's a column:

ColumnX = var _fcst = TableA[FCST]
RETURN
IF (_fcst = "CQ",
CALCULATE(SUM(TableA[REVENUE]), 
    FILTER(TableA, TableA[WEEK] = 4 && TableA[STAGE] IN {"07", "08"} && TableA[FCST] = _fcst)))

If it's not quite what is required at least you can edit it for desired result

Anonymous
Not applicable

Hi @HotChilli ,

Thanks for quick response !! 
500 should be shown as a card on a page and week 4 is dynamic , which means for current qtr as of now max week data is week 4 hence it is taking as week 4 , in next week max week will become week 5. I want the week to dynamic something max(week_num)
Here is what i have modified to .

cq = var _fcst = 'Trend'[fcst]
RETURN
IF (_fcst = "CQ",
CALCULATE(SUM('Trend'[REV$M]),
FILTER('Trend', 'Trend'[WEEK_NUM] = 4 && 'Trend'[SS_No] IN {"07", "08"} && 'Trend'[FCST] = _fcst)))


I am getting this error 
A single value for column 'fcst' in table 'Trend' 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.
It is showing the error in 1st line after declaring the variable 
'Trend'[fcst].
what i am expecting is if the conditions met then whatever value is there in Revenue it should be updated in the new column else 0
if you can take a look and provide me a solution it would a great help please!!
Thanks & Regards
Shiv




 

HotChilli
Super User
Super User

1. a measure requires an aggregation (MIN, MAX etc) so it throws the error.

2. The MAX is wrapped round an 'IF' and it needs a column so there's an error.

 

Maybe post some data (as text) and explain what you are trying to do

Anonymous
Not applicable

Hi @HotChilli ,

Thanks for replying!!

Here is some sample data ,

i am looking fcst should be CQ and stage should be either 07 or 08 and sum (revenue) for max of week in this case where ever it is 4 , so the value should be 500

FCSTWEEKSTAGEREVENUE
CQ107100
CQ407300
CQ408200

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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