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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
Community Champion
Community Champion

@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...



Follow on LinkedIn
@ 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!:
DAX For Humans

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.