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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
UpharAnand
Helper II
Helper II

Only one row should show

Hi,

Please review the attached two screenshot and the file.

Screenshot 1.

Here I want to show only 1 row for each source ids which will show status as ACTIVE,Its Subscription Activation date and Last Cancellation date. user have multiple activation and cancellation date but I only want to show latest status = Active and its last cancellation date. I want output as given in screenshot 2. Please scroll down for screenshot 2

UpharAnand_0-1718969205734.png

 

Scrrenshot2

UpharAnand_1-1718969378803.png

I have written a dax function but it is showing me output like in screenshot 1 but I need output as screenshot 2

 

Please help me for correct dax function.

I am uploading the file, kindly review it

https://drive.google.com/file/d/1DYGnjoSLAa_dJasYNnQU7kSIkqxDS2Mf/view?usp=drivesdk

 

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @UpharAnand 

Your table is currently returning multiple rows because there are still unique rows at the status level and subscription number level.

To get to one row at the sourceid level, you need to aggregate all of these columns.
Please create measures like :

Latest Status =
VAR LatestDate =
    CALCULATE(
        MAX('act_subscription'[subscriptionactivateddate]),
        ALLEXCEPT('act_subscription', 'act_subscription'[sourceid])
    )
RETURN
    CALCULATE(
        MAX('act_subscription'[status]),
        FILTER(
            'act_subscription',
            'act_subscription'[subscriptionactivateddate] = LatestDate
            && 'act_subscription'[sourceid] = MAX('act_subscription'[sourceid])
        )
    )
 
And :
Latest subscription number =
VAR LatestDate =
    CALCULATE(
        MAX('act_subscription'[subscriptionactivateddate]),
        ALLEXCEPT('act_subscription', 'act_subscription'[sourceid])
    )
RETURN
    CALCULATE(
        MAX('act_subscription'[subscriptionnumber]),
        FILTER(
            'act_subscription',
            'act_subscription'[subscriptionactivateddate] = LatestDate
            && 'act_subscription'[sourceid] = MAX('act_subscription'[sourceid])
        )
    )
Result :
Ritaf1983_0-1718971849255.png

The updated PBIX is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

You seemed to be at the right path already. Since you didn't  need to include non-active status, you can just filter those rows out and another calculation for the lastest subscription number

 

danextian_0-1718973033246.png

 

Latest Subscription = 
VAR MaxSubsDate =
    CALCULATE (
        MAX ( act_subscription[subscriptionactivateddate] ),
        ALLEXCEPT ( act_subscription, act_subscription[sourceid] )
    )
RETURN
    CALCULATE (
        MAX ( act_subscription[subscriptionnumber] ),
        FILTER (
            ALLEXCEPT ( act_subscription, act_subscription[sourceid] ),
            act_subscription[subscriptionactivateddate] = MaxSubsDate
                && act_subscription[status] = "active"
        )
    )









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
Ritaf1983
Super User
Super User

Hi @UpharAnand 

Your table is currently returning multiple rows because there are still unique rows at the status level and subscription number level.

To get to one row at the sourceid level, you need to aggregate all of these columns.
Please create measures like :

Latest Status =
VAR LatestDate =
    CALCULATE(
        MAX('act_subscription'[subscriptionactivateddate]),
        ALLEXCEPT('act_subscription', 'act_subscription'[sourceid])
    )
RETURN
    CALCULATE(
        MAX('act_subscription'[status]),
        FILTER(
            'act_subscription',
            'act_subscription'[subscriptionactivateddate] = LatestDate
            && 'act_subscription'[sourceid] = MAX('act_subscription'[sourceid])
        )
    )
 
And :
Latest subscription number =
VAR LatestDate =
    CALCULATE(
        MAX('act_subscription'[subscriptionactivateddate]),
        ALLEXCEPT('act_subscription', 'act_subscription'[sourceid])
    )
RETURN
    CALCULATE(
        MAX('act_subscription'[subscriptionnumber]),
        FILTER(
            'act_subscription',
            'act_subscription'[subscriptionactivateddate] = LatestDate
            && 'act_subscription'[sourceid] = MAX('act_subscription'[sourceid])
        )
    )
Result :
Ritaf1983_0-1718971849255.png

The updated PBIX is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
danextian
Super User
Super User

Hi @UpharAnand ,

but I only want to show latest status = Active and its last cancellation date

 

What if there isi no active status for a source id?

danextian_0-1718971557336.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Sorry for this confusion. if there is no active status then that source id will not be shown in the visual.

 

You can also make changes as per your logic.

You seemed to be at the right path already. Since you didn't  need to include non-active status, you can just filter those rows out and another calculation for the lastest subscription number

 

danextian_0-1718973033246.png

 

Latest Subscription = 
VAR MaxSubsDate =
    CALCULATE (
        MAX ( act_subscription[subscriptionactivateddate] ),
        ALLEXCEPT ( act_subscription, act_subscription[sourceid] )
    )
RETURN
    CALCULATE (
        MAX ( act_subscription[subscriptionnumber] ),
        FILTER (
            ALLEXCEPT ( act_subscription, act_subscription[sourceid] ),
            act_subscription[subscriptionactivateddate] = MaxSubsDate
                && act_subscription[status] = "active"
        )
    )









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.