1

I have a table with two columns which contains date and sales order. I want to create an another table using DAX which contains distinct sales orders getting data from sales order column for making some relationships with other tables. I use below DAX code, but my issue is even after filtering the data from the sheet1 table my DAX table shows all the distinct sales orders from the sales order table. I want to get distinct sales order from filtered table if there any filter for the date.

Distinct Sales orders = DISTINCT(Sheet1[Sales Order])

enter image description here

7
  • Are you required to do this in dax or can you use any database? I can help you understand the database structure, logic and terms in a relational database, but I do not know dax. Commented Apr 15, 2023 at 7:24
  • I want do in DAX . I want to know how to apply distinct value function for a table for getting distinct values from the filtered column not from the entire column. Currently my table measure is getting values I wanted. But not respecting to date slicer in sales order table. Commented Apr 15, 2023 at 7:31
  • Take a look at my notes. 99.9% of the programmers out there know SQL and not DAX. So if you can explain the SQL, you might find the equivalent with a google search. Sorry I couldn't help more. Commented Apr 15, 2023 at 7:47
  • SQL syntax of "DISTINCT ORDER_ID has the DAX syntax of DISTINCT ( SALES_ORDER[ORDER_ID] ) Commented Apr 15, 2023 at 7:57
  • I haven't tag SQL for this post. I need only a DAX modification. I want approach this using power bi only. Thanks Commented Apr 15, 2023 at 8:00

1 Answer 1

0

This is an attempt, because I've never used DAX before today. I will delete if this doesn't work for you.

Using the SQL table name and column names from my notes below, we have this DAX syntax.

filterDate = DATE("2023", "4", "1")

EVALUATE
 (
    SELECTCOLUMNS (
        DISTINCT ( 'SALES_ORDER'[ORDER_ID] ),
        'SALES_ORDER'[ORDER_DATE]
    ),
    FILTER (
        'SALES_ORDER'[ORDER_DATE] = filterDate
    )
)

Using your DAX table name and DAX column names, we have this DAX syntax.

filterDate = DATE("2023", "4", "1")

EVALUATE
 (
    SELECTCOLUMNS (
        DISTINCT ( 'Sheet1'[SALES_ORDER] ),
        'Sheet1'[DATE]
    ),
    FILTER (
        'Sheet1'[DATE] = filterDate
    )
)

This was an attempt to convert SQL to DAX based on what the SQL query would look like.

SELECT
  DISTINCT ORDER_ID, ORDER_DATE
FROM
  SALES_ORDER
WHERE
  ORDER_DATE = '2023-04-01'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.