Forum Discussion
Evolution with condition
Hi all,
I have a pretty straightforward table with 3 columns:
Year | Number of sales | YOY
Basically what I would like to do is calculate the YoY evolution of sales.
The only twist is that when the Year selected is 2022, then only rows with "Yes" in column YOY should be considered.
Any idea how to construct this DAX formula?
Thanks a lot,
Arthur
13 Replies
- Samarth_18Community Champion
Hi Arthur_NS ,
Please try this:-
measure = VAR selected_year = SELECTEDVALUE ( table[year] ) RETURN CALCULATE ( SUM ( table[number of sales] ), FILTER ( table, table[year] = selected_year - 1 && table[YOY] = "Yes" ) )Thanks,
Samarth
- Arthur_NSHelper I
Thanks but I get this
- Samarth_18Community Champion
Arthur_NS try this:-
measure = VAR selected_year = SELECTEDVALUE ( table[year] ) RETURN CALCULATE ( SUM ( table[number of sales] ), FILTER ( table, int(table[year]) = int(selected_year) - 1 && table[YOY] = "Yes" ) )
- Arthur_NSHelper I
Sorry but I still get the same
- Samarth_18Community Champion
Arthur_NS is it possible for you to share PBIX file after removing sensitive data?
- Arthur_NSHelper I
Hello,
The pbix file can be found here: https://drive.google.com/file/d/14ff94knR1CG59264cK6_B9oZBSl1Ini3/view?usp=sharing
Also a little explanation with my table, and the calculation I'm trying to get at
Thank you