Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hi,
I am trying to use DAX to get the Sales value from a table, where I have multiple Sales line per ID, each one might have the same date, different date, or no date.
I am trying to only read the Sales values once per ID, where the Date is Max(Date).
This is the original table:
And this is the result I am trying to achieve:
I was able to use DAX to get the Maxdate (latest date) per ID:
Max Date =
CALCULATE(
MAX(‘Table’[Date]),
FILTER(‘Table’[Date]), EARLIER(‘Table’[ID]) = ‘Table’[ID])
)
Than, I tried using SUMX, with 2-filter criteria, but the formula below is giving an error:
Unique Sale =
CALCUALTE(
SUMX(‘Table’, ‘Table’[Sales]),
‘Table’[Date] = ‘Table’[Max Date]
&& ‘Table’[ID] = ‘Table’[ID]
)
Thanks for your time.
Solved! Go to Solution.
In case you have date table, you can get cumulative value like this. But in this case it might not work. But try out
Cumm Sales = CALCULATE([Sales],filter(date,date[date] <=maxx(date,date[date])))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin
Try
Measure =
VAR __id = MAX ( 'Table'[ID] )
VAR __date = CALCULATE ( MAX( 'Table'[Date] ), ALLSELECTED ( 'Table' ), 'Table'[ID] = __id )
RETURN CALCULATE ( sum ( 'Table'[sales] ), VALUES ( 'Table'[ID] ), 'Table'[id] = __id, 'Table'[date] = __date )
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin
@amitchandak thanks, this measure works, I was hoping to use a Column (not a measure)
The second part, is creating a cummulative Visual, like with a table below:
Not sure how to create accumulative DAX using EARLIER and a Measure.
In case you have date table, you can get cumulative value like this. But in this case it might not work. But try out
Cumm Sales = CALCULATE([Sales],filter(date,date[date] <=maxx(date,date[date])))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin
Check out the November 2023 Power BI update to learn about new features.