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
snarasi_83
Frequent Visitor

Need Help on DAX measure

Hi,

 

I have fair knowledge in Power BI , not able to figure out one piece of puzzle.

I have a simple table below data

 

Sample Data:

enddatestatusBrandDue
11/2/2022FailedLenova1
12/10/2022FailedMicrosoft1
1/22/2023FailedMicrosoft1
3/10/2023FailedMicrosoft1
3/28/2023CompleteMicrosoft1
3/30/2023OntrackMicrosoft1
4/10/2023OntrackLenova1
4/17/2023RiskLenova1
5/31/2023RiskMicrosoft1
5/30/2023OntrackHP1
5/10/2023OntrackLenova1
11/10/2023RiskMicrosoft1
12/10/2023InProgressHP1
1/10/2024RiskMicrosoft1

 

Expected Result :

Clients wants count of status by Months . (Conditions are)

  • Anything less than current month (3/1/2023) should be summed by status as 1 row. 
  • Current Month and future months row wise.
  • Entere table is filtered for previous 3 months , Current and next 3 months (Total 7 Months)

snarasi_83_0-1679865058889.png

Please attach pbix file if u can resolve 

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Here's one approach. You can add a calculated column with the expression below and then use it in your visual (filtering out the two More Than values). You'll also need to work out a sort-by column to get them in your desired order.

ppm1_0-1679879359073.png

 

MonthForVisual =
VAR thisSOM =
    EOMONTH ( 'Status'[enddate], -1 ) + 1
VAR todaySOM =
    EOMONTH ( TODAY (), -1 ) + 1
VAR MonthsDiff =
    DATEDIFF ( todaySOM, thisSOM, MONTH )
RETURN
    SWITCH (
        TRUE (),
        MonthsDiff < -3, "MT 3 Mos Ago",
        MonthsDiff < 0, "Prev 3 Mos",
        MonthsDiff < 4, FORMAT ( 'Status'[enddate], "MMM" ),
        "MT 3 Mos From Now"
    )

 

Pat

Microsoft Employee

View solution in original post

4 REPLIES 4
ppm1
Solution Sage
Solution Sage

Here's one approach. You can add a calculated column with the expression below and then use it in your visual (filtering out the two More Than values). You'll also need to work out a sort-by column to get them in your desired order.

ppm1_0-1679879359073.png

 

MonthForVisual =
VAR thisSOM =
    EOMONTH ( 'Status'[enddate], -1 ) + 1
VAR todaySOM =
    EOMONTH ( TODAY (), -1 ) + 1
VAR MonthsDiff =
    DATEDIFF ( todaySOM, thisSOM, MONTH )
RETURN
    SWITCH (
        TRUE (),
        MonthsDiff < -3, "MT 3 Mos Ago",
        MonthsDiff < 0, "Prev 3 Mos",
        MonthsDiff < 4, FORMAT ( 'Status'[enddate], "MMM" ),
        "MT 3 Mos From Now"
    )

 

Pat

Microsoft Employee

Awesome got your solution . it works . 

Any simple solution it can be sorted.

Greg_Deckler
Super User
Super User

@snarasi_83 You'll need to use a disconnected table as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  I tried but i am not able to figure out the first condition.

  • Anything less than current month (3/1/2023) should be summed by status as 1 row. 

Any other option ? or implementation . If solved please upload pbix file

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.

Top Solution Authors