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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

IF Slicer Date period is x days show visual. Otherwise show other visual. - Using DAX

I have a linechart and I have uused date slicers to select a period. My dataset consists of the following information: Storenumber, Date, Actual Sales, Model Type(Short and Long), prediciton. The short model shows a different prediction then the long prediction. So see the table below:

Store NumberDateActual SalesModel TypePrediction
12-3-20202000Short2100
12-3-20202000Long2200
22-3-20202100Short2500
22-3-20202100Long2600

 

Now what I want is if the period selected is longer then 7 days I want the line chart to show only the Long model data. If the period selected is shorter then 7 days I want it to show short model data.

 

I hope someone can help using DAX 

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @Anonymous , 

You could refer to my sample for details(use below measure).

Measure = IF("A" IN VALUES(T5[A or B]),  CALCULATE(SUM(T5[Sales]), FILTER(T5,T5[A or B]="A")), SUM(T5[Sales]))

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
dax
Community Support
Community Support

Hi @Anonymous , 

I am not clear about your requirement, if possible, could you please inform me more detailed information? such as "period selected", did you mean that you want to date range slicer? And you said that " line chart to show only the Long model data", what is "long model data"?  Please show me your expected output, then I will help you more correctly.

Please do mask sensitive data before uploading.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Hi thank you for your reply, sorry I still haven't figured it out yet. But lets forget about short or long, I will try to create a simpler sketch. Lets call it A and B. This is the data. 

 

DateNumberA or BSales
1-1-20011A1000
1-1-20011B1200
1-2-20011A1000
1-2-20011B1200
1-3-20011B1500
1-4-20011B1600
1-5-20011B1700

This is the output. You can select a period using the date slicer. The black line is in this case the A Value and the green line is the B value in the plot.

Example.png

 

In some cases A has no value, therefore it is not shown in the plot. However, once the A has a value I only want the plot to show the A value in the line chart and NOT the B value line as shown in the plot above. 

dax
Community Support
Community Support

Hi @Anonymous , 

You could refer to my sample for details(use below measure).

Measure = IF("A" IN VALUES(T5[A or B]),  CALCULATE(SUM(T5[Sales]), FILTER(T5,T5[A or B]="A")), SUM(T5[Sales]))

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.