If statement Dax function as a measure

spycein

Board Regular
Joined
Mar 8, 2014
Messages
135
Office Version
  1. 365
Platform
  1. Windows
Hello Everyone,
I am looking for a dax measure function based on the following logic
i have three tables,

Table No.1

Category

<tbody>
</tbody>
Online Price

<tbody>
</tbody>
Offline Price

<tbody>
</tbody>
Laptop

<tbody>
</tbody>
3800042000
TV

<tbody>
</tbody>
4500050000
Mobile

<tbody>
</tbody>
1500017000
Microwave

<tbody>
</tbody>
2000023000

<tbody>
</tbody>

Table No.2

Product Name

<tbody>
</tbody>
Category

<tbody>
</tbody>
Lenovo

<tbody>
</tbody>
Laptop

<tbody>
</tbody>
Sony Bravia

<tbody>
</tbody>
TV

<tbody>
</tbody>
Samsung

<tbody>
</tbody>
Mobile

<tbody>
</tbody>
LG

<tbody>
</tbody>
Microwave

<tbody>
</tbody>

<tbody>
</tbody>

Table No.3

Product Name

<tbody>
</tbody>
Qnty

<tbody>
</tbody>
Mode

<tbody>
</tbody>
Total Sale Amount ( A Dax Measure not a column)

<tbody>
</tbody>
Lenovo

<tbody>
</tbody>
3
Online

<tbody>
</tbody>
?
Sony Bravia

<tbody>
</tbody>
4
Offline

<tbody>
</tbody>
?
Samsung

<tbody>
</tbody>
5
Online

<tbody>
</tbody>
?
LG

<tbody>
</tbody>
2
Offline

<tbody>
</tbody>
?

<tbody>
</tbody>

I am looking a dax function as a measure which would return the total sold price amount.
I dont want to add a column or create another separate table.
Thank you so much.
Best Regards
Shib
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Why is your pricing at the category level and not the product level? This implies that all products in a category are always the same price instead of each product in a category having its own price. This sounds wrong to me. regardless, I suggest you merge table 1 and 2 I to a single table on data load (I will call it table 4). You can use power query for this. Then join the new table to table 3 with a 1 to many relationship (table4 to table 3) on product name.
The DAX is a bit tricky, but a variable syntax measure should help. This will need to be tested but I think it is right.


Result =
SUMX (
table4,
VAR offlineprice = table4[offline]
VAR onlineprice = table3[online]
RETURN
CALCULATE (
VAR mode =
SELECTEDVALUE ( table3[mode] )
RETURN
SWITCH ( mode, "online", onlineprice, "offline", offlineprice, 0 )
* SUM ( table3[qty] )
)
)
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,995
Members
448,539
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top