Forum Discussion
Using DIVIDE, SUM, and EARLIER
I'm trying to create a measure using DIVIDE, SUM, and MAX. The DAX expression I'm trying to use is :
12 Replies
- amitchandakSuper User
alicewang96 , Try like
DIVIDE(
CALCULATE(
SUM(table_1[Net Amount Paid]), table_2[ID] = "12345", filter(date_table,'date_table'[Dispense Date] <= MAX('date_table'[Dispense Date]))), 10000000)- alicewang96Helper I
I'm getting the error:
The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
- amitchandakSuper User
alicewang96 , Try this
DIVIDE(
CALCULATE(
SUM(table_1[Net Amount Paid]), filter(table_2, table_2[ID] = "12345"), filter(date_table,'date_table'[Dispense Date] <= MAX('date_table'[Dispense Date]))), 10000000)hope Net Amount Paid is a column not measure. If measure do not use sum
- Greg_DecklerCommunity Champion
alicewang96 - Not sure about the EARLIER part, but maybe:
New Measure = DIVIDE( SUMX(FILTER(table_1), table_2[ID] = "12345" && 'date_table'[Dispense Date] <= MAX('date_table'[Dispense Date])),[Net Amount Paid]), 10000000 ) - Ashish_MathurSuper User
Hi,
Create a Calendar Table and create a calculated column for Year. Build a relationship from the Date column of your table_1 to the Date column of the Calendar Table. To your visual, drag Year from the Calendar Table. Write this measure
New Measure = DIVIDE(CALCULATE(SUM(table_1[Net Amount Paid]), table_2[ID] = "12345"),datesbetween(Calendar[date],MINX(ALL(Calendar),Calendar[date]),max(calendar[date]))),10000000))Hope this helps. If it does, then share the link from where i can download your PBI file. - AnonymousNot applicable
Hi alicewang96 ,
I am not clear about the relationship between date_table and table_1 in the information you provided.
In my understanding, you want to calculate the total from that year to the present,right?
You could use the following fomula:
yearColumn = YEAR ( 'Table_1'[Date] )Measure = DIVIDE ( CALCULATE ( SUM ( 'Table_1'[Net Amount Paid] ), FILTER ( ALL ( Table_1 ), 'Table_1'[ID] = 12345 && 'Table_1'[yearColumn] <= MAX ( [yearColumn] ) ) ), 10000000 )My visualization looks like this:
Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.
Best Regards,
Eyelyn Qin
- alicewang96Helper I
Anonymous The [ID] column isn't in table_1, it's in a separate table called table_2. How can I adjust your expression to account for this? I've tried adding an extra FILTER after && for table_2, but it's giving me an error.