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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
BSM1985
Helper IV
Helper IV

Calculations

Hi Team,

I would need your help in creating the below 2 calculations using DAX.

 

Calculation1: Measure
SUM(

CASE WHEN [COLUMN1] = [COLUMN2] AND [COLUMN3] = 'A' THEN 1
END for [COLUMN4

])

 

Calculation2: Column
[COLUMN1] = maximum(COLUMN1 for COLUMN2)

1 ACCEPTED SOLUTION

@BSM1985 , 

Second one is not clear. Try like

 

New column
sumx(filter(Table, COLUMN4 = earlier([COLUMN4])),if( [COLUMN1] = [COLUMN2] AND [COLUMN3] = "A",1,0))

Maxx(filter(Table, COLUMN2 = earlier([COLUMN2])),COLUMN1) -Minx(filter(Table, COLUMN2 = earlier([COLUMN2])),COLUMN1)

 

New measure

sumx(filter(allselected(Table), Table[COLUMN4] = max(Table[COLUMN4])),if( Table[COLUMN1] = Table[COLUMN2] AND Table[COLUMN3] = "A",1,0))

Maxx(filter(allselected(Table), Table[COLUMN2] = max(Table[COLUMN2])),Table[COLUMN1]) -Minx(filter(Table, Table[COLUMN2] = max(Table[COLUMN2])),Table[COLUMN1])

 

See if my Dax Vs SQL Series can help: https://www.youtube.com/watch?v=WlvQ_SGy4iA&list=PLPaNVDMhUXGZNyKU0PgG2g3P0c6CPjMnj

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

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Explain the question in simple English and on a dummy dataset show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@BSM1985 , Try like

new columns

COLUMN4 = Sumx(Table , Table[COLUMN1] = Table[COLUMN2] AND Table[COLUMN3] = "A",1,blank())

COLUMN1 = MAx(Table[COLUMN1], Table[COLUMN2])

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

Thanks @amitchandak  for your reply.

 

Soryy I was not clear. Below are the calculations in SQL terms:

 

calculation1:

SELECT
Sum(CASE WHEN [COLUMN1] = [COLUMN2] AND [COLUMN3] = 'A' THEN 1 END) OVER (partition BY COLUMN4) AS CALCULATION1
FROM TABLE

 

Calculation2:
SELECT
Min(COLUMN1)= Max(Max(COLUMN1)) OVER ( partition BY COLUMN2) AS CALCULATION2
FROM TABLE

@BSM1985 , 

Second one is not clear. Try like

 

New column
sumx(filter(Table, COLUMN4 = earlier([COLUMN4])),if( [COLUMN1] = [COLUMN2] AND [COLUMN3] = "A",1,0))

Maxx(filter(Table, COLUMN2 = earlier([COLUMN2])),COLUMN1) -Minx(filter(Table, COLUMN2 = earlier([COLUMN2])),COLUMN1)

 

New measure

sumx(filter(allselected(Table), Table[COLUMN4] = max(Table[COLUMN4])),if( Table[COLUMN1] = Table[COLUMN2] AND Table[COLUMN3] = "A",1,0))

Maxx(filter(allselected(Table), Table[COLUMN2] = max(Table[COLUMN2])),Table[COLUMN1]) -Minx(filter(Table, Table[COLUMN2] = max(Table[COLUMN2])),Table[COLUMN1])

 

See if my Dax Vs SQL Series can help: https://www.youtube.com/watch?v=WlvQ_SGy4iA&list=PLPaNVDMhUXGZNyKU0PgG2g3P0c6CPjMnj

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

Hi Amit @amitchandak ,

 

Thanks much for this. This is what I was looking for.

I will definitely go thru your Youtube seris on DAX vs SQL.

 

Cheers.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors